From 28c21fa048db0f1850e533c82a13d01c98de7ea1 Mon Sep 17 00:00:00 2001 From: Pauli Date: Wed, 17 Mar 2021 12:55:37 +1000 Subject: [PATCH] evp: fix coverity 1445872 - dereference after null check Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/14589) --- crypto/evp/digest.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index d256cbe140d..494e0f5646d 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -457,7 +457,12 @@ int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *md, size_t size) OSSL_PARAM params[2]; size_t i = 0; - if (ctx->digest == NULL || ctx->digest->prov == NULL) + if (ctx->digest == NULL) { + ERR_raise(ERR_LIB_EVP, EVP_R_INVALID_NULL_ALGORITHM); + return 0; + } + + if (ctx->digest->prov == NULL) goto legacy; if (ctx->digest->dfinal == NULL) { -- 2.47.2