From: Nils Larsch Date: Tue, 5 Dec 2006 21:21:37 +0000 (+0000) Subject: avoid duplicate entries in add_cert_dir() X-Git-Tag: OpenSSL_0_9_8k^2~1043 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=fa9ac569b8d5fa779a326b91b3ef73646d82969c;p=oweals%2Fopenssl.git avoid duplicate entries in add_cert_dir() PR: 1407 Submitted by: Tomas Mraz --- diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c index b0a4afae83..f02168ab92 100644 --- a/crypto/x509/by_dir.c +++ b/crypto/x509/by_dir.c @@ -218,7 +218,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')) { @@ -230,10 +230,12 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type) for (j=0; j < sk_BY_DIR_ENTRY_num(ctx->dirs); j++) { ent = sk_BY_DIR_ENTRY_value(ctx->dirs, j); - if (strncmp(ent->dir,ss,(unsigned int)len) == 0) - continue; + if (strlen(ent->dir) == len && + strncmp(ent->dir,ss,(unsigned int)len) == 0) + break; } - + if (j < sk_BY_DIR_ENTRY_num(ctx->dirs)) + continue; if (ctx->dirs == NULL) { ctx->dirs = sk_BY_DIR_ENTRY_new_null(); @@ -264,7 +266,6 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type) } if (*p == '\0') break; - p++; } return 1; }