Return 1 when openssl req -addext kv is duplicated
authorkinichiro <kinichiro.inoguchi@gmail.com>
Thu, 5 Dec 2019 11:00:50 +0000 (20:00 +0900)
committerTomas Mraz <tmraz@fedoraproject.org>
Mon, 16 Dec 2019 14:05:35 +0000 (15:05 +0100)
CLA: trivial

Fixes #10273

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10578)

apps/req.c

index 76bbbeb555460dd510ed624901046dd9c5935fb1..87994ceb7cc047d9129c94211ff553cfee6b3f9c 100644 (file)
@@ -214,9 +214,12 @@ static int duplicated(LHASH_OF(OPENSSL_STRING) *addexts, char *kv)
     *p = '\0';
 
     /* Finally have a clean "key"; see if it's there [by attempt to add it]. */
-    if ((p = (char *)lh_OPENSSL_STRING_insert(addexts, (OPENSSL_STRING*)kv))
-        != NULL || lh_OPENSSL_STRING_error(addexts)) {
-        OPENSSL_free(p != NULL ? p : kv);
+    p = (char *)lh_OPENSSL_STRING_insert(addexts, (OPENSSL_STRING*)kv);
+    if (p != NULL) {
+        OPENSSL_free(p);
+        return 1;
+    } else if (lh_OPENSSL_STRING_error(addexts)) {
+        OPENSSL_free(kv);
         return -1;
     }