x509/by_dir.c: fix run-away pointer.

fix run-away pointer (and potential SEGV) when adding duplicates in
add_cert_dir.

PR: 3261
Reported by: Marian Done

(Imported from upstream's 83fe7b9c8321d5ffb6bfe67df85ed66ceb97102f)
diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c
index 8b8d0d4..2387792 100644
--- a/crypto/x509/by_dir.c
+++ b/crypto/x509/by_dir.c
@@ -210,7 +210,7 @@
 
 	s=dir;
 	p=s;
-	for (;;p++)
+	do
 		{
 		if ((*p == ':') || (*p == '\0'))
 			{
@@ -256,9 +256,7 @@
 				return 0;
 				}
 			}
-		if (*p == '\0')
-			break;
-		}
+		} while (*p++ != '\0');
 	return 1;
 	}