Fix coverity CID #1458645 - Dereference before NULL check in rsa_digest_verify_final()
authorShane Lontis <shane.lontis@oracle.com>
Tue, 11 Aug 2020 06:33:19 +0000 (16:33 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Mon, 24 Aug 2020 01:19:28 +0000 (11:19 +1000)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)

providers/implementations/signature/rsa.c

index 7e2de96e839884033b38a4aac6488b631041d9f6..1a2238f0a86126ad886804f4a7925ac173b4146f 100644 (file)
@@ -775,10 +775,11 @@ static int rsa_digest_sign_final(void *vprsactx, unsigned char *sig,
     unsigned char digest[EVP_MAX_MD_SIZE];
     unsigned int dlen = 0;
 
+    if (prsactx == NULL)
+        return 0;
     prsactx->flag_allow_md = 1;
-    if (prsactx == NULL || prsactx->mdctx == NULL)
+    if (prsactx->mdctx == NULL)
         return 0;
-
     /*
      * If sig is NULL then we're just finding out the sig size. Other fields
      * are ignored. Defer to rsa_sign.