From: Shane Lontis Date: Tue, 11 Aug 2020 06:50:10 +0000 (+1000) Subject: Fix coverity CID #1458641 - Dereference before NULL check when setting ctx->flag_allo... X-Git-Tag: openssl-3.0.0-alpha7~500 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db1319b706b8f3b0d8d05d766da720812afc28c6;p=thirdparty%2Fopenssl.git Fix coverity CID #1458641 - Dereference before NULL check when setting ctx->flag_allow_md in rsa.c Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/12628) --- diff --git a/providers/implementations/signature/rsa.c b/providers/implementations/signature/rsa.c index 1a2238f0a86..ca7f6f23b95 100644 --- a/providers/implementations/signature/rsa.c +++ b/providers/implementations/signature/rsa.c @@ -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; /*