Skip to content

Commit 7d4e430

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix memory leaks when sk_X509_new_null() fails
2 parents 6d02e51 + 7754eaf commit 7d4e430

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ PHP NEWS
3636
. Fixed bug GH-20818 (Segfault in Tracing JIT with object reference).
3737
(khasinski)
3838

39+
- OpenSSL:
40+
. Fix memory leaks when sk_X509_new_null() fails. (ndossche)
41+
3942
- Phar:
4043
. Fixed bug GH-20882 (buildFromIterator breaks with missing base directory).
4144
(ndossche)

ext/openssl/openssl.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,6 +2616,9 @@ PHP_FUNCTION(openssl_pkcs7_encrypt)
26162616
}
26172617

26182618
recipcerts = sk_X509_new_null();
2619+
if (recipcerts == NULL) {
2620+
goto clean_exit;
2621+
}
26192622

26202623
/* get certs */
26212624
if (Z_TYPE_P(zrecipcerts) == IS_ARRAY) {
@@ -3230,6 +3233,9 @@ PHP_FUNCTION(openssl_cms_encrypt)
32303233
}
32313234

32323235
recipcerts = sk_X509_new_null();
3236+
if (recipcerts == NULL) {
3237+
goto clean_exit;
3238+
}
32333239

32343240
/* get certs */
32353241
if (Z_TYPE_P(zrecipcerts) == IS_ARRAY) {

ext/openssl/openssl_backend_common.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,9 @@ STACK_OF(X509) *php_openssl_array_to_X509_sk(zval * zcerts, uint32_t arg_num, co
864864
bool free_cert;
865865

866866
sk = sk_X509_new_null();
867+
if (sk == NULL) {
868+
goto clean_exit;
869+
}
867870

868871
/* get certs */
869872
if (Z_TYPE_P(zcerts) == IS_ARRAY) {

0 commit comments

Comments
 (0)