From: Matt Caswell Date: Wed, 11 Mar 2015 15:41:52 +0000 (+0000) Subject: Fix EVP_DigestInit_ex with NULL digest X-Git-Tag: OpenSSL_1_0_2a~37 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ff2459b91877959bc1a3a8a927c6b5f473530f86;p=oweals%2Fopenssl.git Fix EVP_DigestInit_ex with NULL digest Calling EVP_DigestInit_ex which has already had the digest set up for it should be possible. You are supposed to be able to pass NULL for the type. However currently this seg faults. Reviewed-by: Andy Polyakov (cherry picked from commit a01087027bd0c5ec053d4eabd972bd942bfcd92f) --- diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index bd7760d0c9..f2643f3248 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -203,9 +203,12 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl) ctx->engine = impl; } else ctx->engine = NULL; - } else if (!ctx->digest) { - EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_NO_DIGEST_SET); - return 0; + } else { + if (!ctx->digest) { + EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_NO_DIGEST_SET); + return 0; + } + type = ctx->digest; } #endif if (ctx->digest != type) {