]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix null pointer check in pkey_dh_derive to ensure both keys are set
authorritoban23 <ankudutt101@gmail.com>
Wed, 13 Aug 2025 20:19:17 +0000 (01:49 +0530)
committerTodd Short <todd.short@me.com>
Fri, 22 Aug 2025 15:30:03 +0000 (11:30 -0400)
CLA: trivial

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/28259)

(cherry picked from commit fc84d46d7227886152be00618889a521e9132ef3)
(cherry picked from commit 0163c6ad1f7cec08f59e9f736d36073d01ae7ae5)
(cherry picked from commit 257c3dd6cdbe9b1bde353fa45445b1319de6ffc3)
(cherry picked from commit eb1e036728bac6e450b2e42372487cf5e3e7a175)

crypto/dh/dh_pmeth.c

index 3b75a537b3e0255f64b9c7b8398286ec597a6cf2..74bef9370d3a2fe0569a00e3399f6af93739de1c 100644 (file)
@@ -408,7 +408,7 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key,
     }
     dh = (DH *)EVP_PKEY_get0_DH(ctx->pkey);
     dhpub = EVP_PKEY_get0_DH(ctx->peerkey);
-    if (dhpub == NULL) {
+    if (dhpub == NULL || dh == NULL) {
         ERR_raise(ERR_LIB_DH, DH_R_KEYS_NOT_SET);
         return 0;
     }