From: x2018 Date: Mon, 29 Nov 2021 07:32:47 +0000 (+0800) Subject: check the return value of EVP_MD_fetch in ecdh_exch.c:285 & dh_exch.c:347 X-Git-Tag: openssl-3.2.0-alpha1~3146 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=04e3ab64d58bb43efc4392d12c607bb4b5a2c562;p=thirdparty%2Fopenssl.git check the return value of EVP_MD_fetch in ecdh_exch.c:285 & dh_exch.c:347 Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/17153) --- diff --git a/providers/implementations/exchange/dh_exch.c b/providers/implementations/exchange/dh_exch.c index 6edf57e0ae4..4bea7af4ec5 100644 --- a/providers/implementations/exchange/dh_exch.c +++ b/providers/implementations/exchange/dh_exch.c @@ -345,12 +345,13 @@ static int dh_set_ctx_params(void *vpdhctx, const OSSL_PARAM params[]) EVP_MD_free(pdhctx->kdf_md); pdhctx->kdf_md = EVP_MD_fetch(pdhctx->libctx, name, mdprops); + if (pdhctx->kdf_md == NULL) + return 0; if (!ossl_digest_is_allowed(pdhctx->libctx, pdhctx->kdf_md)) { EVP_MD_free(pdhctx->kdf_md); pdhctx->kdf_md = NULL; - } - if (pdhctx->kdf_md == NULL) return 0; + } } p = OSSL_PARAM_locate_const(params, OSSL_EXCHANGE_PARAM_KDF_OUTLEN); diff --git a/providers/implementations/exchange/ecdh_exch.c b/providers/implementations/exchange/ecdh_exch.c index 64b163f5e0c..bf6f5c23662 100644 --- a/providers/implementations/exchange/ecdh_exch.c +++ b/providers/implementations/exchange/ecdh_exch.c @@ -283,12 +283,13 @@ int ecdh_set_ctx_params(void *vpecdhctx, const OSSL_PARAM params[]) EVP_MD_free(pectx->kdf_md); pectx->kdf_md = EVP_MD_fetch(pectx->libctx, name, mdprops); + if (pectx->kdf_md == NULL) + return 0; if (!ossl_digest_is_allowed(pectx->libctx, pectx->kdf_md)) { EVP_MD_free(pectx->kdf_md); pectx->kdf_md = NULL; - } - if (pectx->kdf_md == NULL) return 0; + } } p = OSSL_PARAM_locate_const(params, OSSL_EXCHANGE_PARAM_KDF_OUTLEN);