]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
req: fix Coverity 1485137 Explicit null dereference
authorPauli <pauli@openssl.org>
Sun, 30 May 2021 23:26:05 +0000 (09:26 +1000)
committerPauli <pauli@openssl.org>
Tue, 1 Jun 2021 08:46:44 +0000 (18:46 +1000)
Add a check for a non-existent file name when specifying params via file.
Add a check for a failure to determine key type.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15534)

apps/req.c

index a9769b745271685b35997c3fcffcac0a367c9ed8..3b0545fd6e778a1ddf1430c447496d92097764d2 100644 (file)
@@ -1522,6 +1522,12 @@ static EVP_PKEY_CTX *set_keygen_ctx(const char *gstr,
 
         if (strncmp(gstr, "param", len) == 0) {
             expect_paramfile = 1;
+            if (p == NULL) {
+                BIO_printf(bio_err,
+                           "Parameter file requested but no path given: %s\n",
+                           gstr);
+                return NULL;
+            }
         } else {
             keytype = gstr;
             keytypelen = len;
@@ -1569,6 +1575,11 @@ static EVP_PKEY_CTX *set_keygen_ctx(const char *gstr,
         }
         if (keytype == NULL) {
             keytype = EVP_PKEY_get0_type_name(param);
+            if (keytype == NULL) {
+                EVP_PKEY_free(param);
+                BIO_puts(bio_err, "Unable to determine key type\n");
+                return NULL;
+            }
         }
     }