Prepare for next version.
[oweals/openssl.git] / crypto / x509 / by_dir.c
index ea689aed1a2518bf4f02952db1dd0992698b8810..341e0ba6a41da3d2f85fafdc5c92e4f47dc51e5d 100644 (file)
 #include <openssl/lhash.h>
 #include <openssl/x509.h>
 
+#ifdef _WIN32
+#define stat   _stat
+#endif
+
 typedef struct lookup_dir_st
        {
        BUF_MEM *buffer;
@@ -189,7 +193,7 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
 
        s=dir;
        p=s;
-       for (;;)
+       for (;;p++)
                {
                if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0'))
                        {
@@ -198,8 +202,11 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
                        len=(int)(p-ss);
                        if (len == 0) continue;
                        for (j=0; j<ctx->num_dirs; j++)
-                               if (strncmp(ctx->dirs[j],ss,(unsigned int)len) == 0)
-                                       continue;
+                               if (strlen(ctx->dirs[j]) == (size_t)len &&
+                                   strncmp(ctx->dirs[j],ss,(unsigned int)len) == 0)
+                                       break;
+                       if (j<ctx->num_dirs)
+                               continue;
                        if (ctx->num_dirs_alloced < (ctx->num_dirs+1))
                                {
                                ctx->num_dirs_alloced+=10;
@@ -231,7 +238,6 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
                        ctx->num_dirs++;
                        }
                if (*p == '\0') break;
-               p++;
                }
        return(1);
        }