Fix null pointer check in pkey_dh_derive to ensure both keys are set

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 fc84d46d72)
This commit is contained in:
ritoban23 2025-08-14 01:49:17 +05:30 committed by Todd Short
parent 7e8d78d579
commit 0163c6ad1f
No known key found for this signature in database
GPG Key ID: 5EE35E207F7BED27
1 changed files with 1 additions and 1 deletions

View 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); dh = (DH *)EVP_PKEY_get0_DH(ctx->pkey);
dhpub = EVP_PKEY_get0_DH(ctx->peerkey); 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); ERR_raise(ERR_LIB_DH, DH_R_KEYS_NOT_SET);
return 0; return 0;
} }