Fix coverity CID #1458641 - Dereference before NULL check when setting ctx->flag_allo...
authorShane Lontis <shane.lontis@oracle.com>
Tue, 11 Aug 2020 06:50:10 +0000 (16:50 +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 1a2238f0a86126ad886804f4a7925ac173b4146f..ca7f6f23b95a6dee43c40bd1e467003d1527edac 100644 (file)
@@ -725,7 +725,8 @@ static int rsa_digest_signverify_init(void *vprsactx, const char *mdname,
 {
     PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
 
-    prsactx->flag_allow_md = 0;
+    if (prsactx != NULL)
+        prsactx->flag_allow_md = 0;
     if (!rsa_signature_init(vprsactx, vrsa, operation)
         || !rsa_setup_md(prsactx, mdname, NULL)) /* TODO RL */
         return 0;
@@ -811,8 +812,10 @@ int rsa_digest_verify_final(void *vprsactx, const 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;
 
     /*