Fix multiple wrong checks of EVP_PKEY_set1_encoded_public_key

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25811)
This commit is contained in:
Peiwei Hu 2024-10-27 17:04:15 +08:00 committed by Tomas Mraz
parent 1a93be1eab
commit 1273fae170
3 changed files with 3 additions and 3 deletions

View File

@ -65,7 +65,7 @@ static int dh_cms_set_peerkey(EVP_PKEY_CTX *pctx,
pkpeer = EVP_PKEY_new();
if (pkpeer == NULL
|| !EVP_PKEY_copy_parameters(pkpeer, pk)
|| !EVP_PKEY_set1_encoded_public_key(pkpeer, buf, plen))
|| EVP_PKEY_set1_encoded_public_key(pkpeer, buf, plen) <= 0)
goto err;
if (EVP_PKEY_derive_set_peer(pctx, pkpeer) > 0)

View File

@ -111,7 +111,7 @@ static int ecdh_cms_set_peerkey(EVP_PKEY_CTX *pctx,
if (p == NULL || plen == 0)
goto err;
if (!EVP_PKEY_set1_encoded_public_key(pkpeer, p, plen))
if (EVP_PKEY_set1_encoded_public_key(pkpeer, p, plen) <= 0)
goto err;
if (EVP_PKEY_derive_set_peer(pctx, pkpeer) > 0)

View File

@ -3086,7 +3086,7 @@ static int tls_process_cke_dhe(SSL_CONNECTION *s, PACKET *pkt)
goto err;
}
if (!EVP_PKEY_set1_encoded_public_key(ckey, data, i)) {
if (EVP_PKEY_set1_encoded_public_key(ckey, data, i) <= 0) {
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
goto err;
}