diff options
author | Matt Caswell <matt@openssl.org> | 2015-03-11 15:41:52 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-03-12 09:32:22 +0000 |
commit | 0c8f4229995bbb51bd29c314e2d71d7edce229de (patch) | |
tree | 5c69defc16a854d3b7f2e6e3b4777e0a181652d3 | |
parent | cc27bec2b40ca6741125cbeef6a214dfbe1f85f9 (diff) | |
download | openssl-new-0c8f4229995bbb51bd29c314e2d71d7edce229de.tar.gz |
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 <appro@openssl.org>
(cherry picked from commit a01087027bd0c5ec053d4eabd972bd942bfcd92f)
-rw-r--r-- | crypto/evp/digest.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index 386a3f73bc..2e202c8fe0 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -191,9 +191,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) { |