From db1319b706b8f3b0d8d05d766da720812afc28c6 Mon Sep 17 00:00:00 2001 From: Shane Lontis Date: Tue, 11 Aug 2020 16:50:10 +1000 Subject: [PATCH] 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) --- providers/implementations/signature/rsa.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/providers/implementations/signature/rsa.c b/providers/implementations/signature/rsa.c index 1a2238f0a8..ca7f6f23b9 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; /*