x509/by_dir.c: fix run-away pointer (and potential SEGV)
authorAndy Polyakov <appro@openssl.org>
Mon, 24 Feb 2014 14:16:56 +0000 (15:16 +0100)
committerAndy Polyakov <appro@openssl.org>
Mon, 24 Feb 2014 14:16:56 +0000 (15:16 +0100)
when adding duplicates in add_cert_dir.

PR: 3261
Reported by: Marian Done

crypto/x509/by_dir.c

index 27ca515..c6602da 100644 (file)
@@ -218,7 +218,7 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
 
        s=dir;
        p=s;
-       for (;;p++)
+       do
                {
                if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0'))
                        {
@@ -264,9 +264,7 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
                                return 0;
                                }
                        }
-               if (*p == '\0')
-                       break;
-               }
+               } while (*p++ != '\0');
        return 1;
        }