[php-src] master: Fix unchecked BN_bin2bn() call (#22754)
Nora Dossche via GitHub <[email protected]> Mon, 3 Aug 2026 13:05:02 +0000
| Newsgroups | gmane.comp.php.cvs.general |
|---|---|
| Message-ID | <[email protected]> |
Author: Nora Dossche (ndossche)
Committer: GitHub (web-flow)
Pusher: ndossche
Date: 2026-08-03T15:04:59+02:00
Commit: https://github.com/php/php-src/commit/9add43a2f196ab35684b3ec4897166fbbab7931f
Raw diff: https://github.com/php/php-src/commit/9add43a2f196ab35684b3ec4897166fbbab7931f.diff
Fix unchecked BN_bin2bn() call (#22754)
Changed paths:
M ext/openssl/openssl_backend_v1.c
Diff:
diff --git a/ext/openssl/openssl_backend_v1.c b/ext/openssl/openssl_backend_v1.c
index 0c1ac6b955f6..bfd01b673464 100644
--- a/ext/openssl/openssl_backend_v1.c
+++ b/ext/openssl/openssl_backend_v1.c
@@ -589,6 +589,11 @@ zend_string *php_openssl_dh_compute_key(EVP_PKEY *pkey, char *pub_str, size_t pu
}
BIGNUM *pub = BN_bin2bn((unsigned char*)pub_str, (int)pub_len, NULL);
+ if (pub == NULL) {
+ php_openssl_store_errors();
+ return NULL;
+ }
+
zend_string *data = zend_string_alloc(DH_size(dh), 0);
int len = DH_compute_key((unsigned char*)ZSTR_VAL(data), pub, dh);
BN_free(pub);