Coverity 1463574: Null pointer dereferences (REVERSE_INULL)
authorPauli <paul.dale@oracle.com>
Thu, 21 May 2020 03:40:01 +0000 (13:40 +1000)
committerPauli <paul.dale@oracle.com>
Fri, 22 May 2020 07:23:49 +0000 (17:23 +1000)
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/11892)

providers/implementations/keymgmt/rsa_kmgmt.c

index 295cdf61a4b475f1e35fc44eb5e7488bba011780..b237b2784faf43b3427bd14d32b5b5b71895f03c 100644 (file)
@@ -496,6 +496,9 @@ static void *rsa_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg)
     RSA *rsa = NULL, *rsa_tmp = NULL;
     BN_GENCB *gencb = NULL;
 
+    if (gctx == NULL)
+        return NULL;
+
     switch (gctx->rsa_type) {
     case RSA_FLAG_TYPE_RSA:
         /* For plain RSA keys, PSS parameters must not be set */
@@ -513,8 +516,7 @@ static void *rsa_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg)
         return NULL;
     }
 
-    if (gctx == NULL
-        || (rsa_tmp = rsa_new_with_ctx(gctx->libctx)) == NULL)
+    if ((rsa_tmp = rsa_new_with_ctx(gctx->libctx)) == NULL)
         return NULL;
 
     gctx->cb = osslcb;