coverity 1462571 Dereference after null check
authorPauli <paul.dale@oracle.com>
Sun, 26 Apr 2020 23:13:46 +0000 (09:13 +1000)
committerPauli <paul.dale@oracle.com>
Thu, 30 Apr 2020 10:21:33 +0000 (20:21 +1000)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/11651)

apps/lib/app_x509.c

index 89c5960fa6b1cead27ab84b599952eedd2221030..00581aabbd6ce1ee25004b8ba54a116e382d4ee4 100644 (file)
@@ -106,12 +106,15 @@ static int do_x509_ctrl_string(int (*ctrl)(void *object, int cmd,
         cmd = EVP_PKEY_CTRL_SET1_ID; /* ... except we put it in X509 */
 #endif
     } else if (strcmp(stmp, "hexdistid") == 0) {
-        long hexid_len = 0;
-        void *hexid = OPENSSL_hexstr2buf((const char *)vtmp, &hexid_len);
-
-        OPENSSL_free(stmp);
-        stmp = vtmp = hexid;
-        vtmp_len = (size_t)hexid_len;
+        if (vtmp != NULL) {
+            void *hexid;
+            long hexid_len = 0;
+
+            hexid = OPENSSL_hexstr2buf((const char *)vtmp, &hexid_len);
+            OPENSSL_free(stmp);
+            stmp = vtmp = hexid;
+            vtmp_len = (size_t)hexid_len;
+        }
 #ifdef EVP_PKEY_CTRL_SET1_ID
         cmd = EVP_PKEY_CTRL_SET1_ID; /* ... except we put it in X509 */
 #endif