Check the return of EVP_KDF_fetch()
authortangyiqun <tangyiqun@uniontech.com>
Tue, 12 Apr 2022 08:07:17 +0000 (16:07 +0800)
committerTomas Mraz <tomas@openssl.org>
Wed, 13 Apr 2022 10:14:41 +0000 (12:14 +0200)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18096)

(cherry picked from commit 02119faee397565525151eb2ce39c424d129d287)

crypto/dh/dh_kdf.c

index 419e7711d36248209f454207124689b9594de281..97933cb52039a91e08477e02fe9089b87c8f2c13 100644 (file)
@@ -39,6 +39,8 @@ int ossl_dh_kdf_X9_42_asn1(unsigned char *out, size_t outlen,
     const char *mdname = EVP_MD_get0_name(md);
 
     kdf = EVP_KDF_fetch(libctx, OSSL_KDF_NAME_X942KDF_ASN1, propq);
+    if (kdf == NULL)
+        return 0;
     kctx = EVP_KDF_CTX_new(kdf);
     if (kctx == NULL)
         goto err;