evp: fix coverity 1445872 - dereference after null check

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14589)
This commit is contained in:
Pauli 2021-03-17 12:55:37 +10:00
parent 07aa88cccf
commit 28c21fa048
1 changed files with 6 additions and 1 deletions

View File

@ -457,7 +457,12 @@ int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *md, size_t size)
OSSL_PARAM params[2]; OSSL_PARAM params[2];
size_t i = 0; 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; goto legacy;
if (ctx->digest->dfinal == NULL) { if (ctx->digest->dfinal == NULL) {