Skip to content

Commit 87ff547

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix memory leak of X509_STORE in php_openssl_setup_verify() on failure
2 parents 81593cf + 08a9579 commit 87ff547

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ PHP NEWS
2626
. Fix memory leak in intl_datetime_decompose() on failure. (nielsdos)
2727
. Fix memory leak in locale lookup on failure. (nielsdos)
2828

29+
- OpenSSL:
30+
. Fix memory leak of X509_STORE in php_openssl_setup_verify() on failure.
31+
(nielsdos)
32+
2933
- Phar:
3034
. Add missing filter cleanups on phar failure. (nielsdos)
3135
. Fixed bug GH-18642 (Signed integer overflow in ext/phar fseek). (nielsdos)

ext/openssl/openssl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2443,6 +2443,7 @@ static X509_STORE *php_openssl_setup_verify(zval *calist, uint32_t arg_num)
24432443
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(calist), item) {
24442444
zend_string *str = zval_try_get_string(item);
24452445
if (UNEXPECTED(!str)) {
2446+
X509_STORE_free(store);
24462447
return NULL;
24472448
}
24482449

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Memory leak of X509_STORE in php_openssl_setup_verify() on failure
3+
--EXTENSIONS--
4+
openssl
5+
--FILE--
6+
<?php
7+
8+
class MyStringable{
9+
public function __toString(): string {
10+
throw new Error('stop');
11+
}
12+
}
13+
14+
try {
15+
openssl_pkcs7_verify("does not matter", 0, "does not matter", [new MyStringable]);
16+
} catch (Error $e) {
17+
echo $e->getMessage(), "\n";
18+
}
19+
20+
?>
21+
--EXPECT--
22+
stop

0 commit comments

Comments
 (0)