]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
check the return value of EVP_MD_fetch in ecdh_exch.c:285 & dh_exch.c:347
authorx2018 <xkernel.wang@foxmail.com>
Mon, 29 Nov 2021 07:32:47 +0000 (15:32 +0800)
committerTomas Mraz <tomas@openssl.org>
Tue, 4 Jan 2022 11:30:12 +0000 (12:30 +0100)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17153)

providers/implementations/exchange/dh_exch.c
providers/implementations/exchange/ecdh_exch.c

index 6edf57e0ae43fd9588db5aee149549e523628ea1..4bea7af4ec5f9051f207dd923f35b331ccc5fe17 100644 (file)
@@ -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);
index 64b163f5e0cd8e19a0ea225b8d0ff4eb9c64378b..bf6f5c2366284d48d43d0ae922b788d2c00ae11e 100644 (file)
@@ -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);