File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ PHP NEWS
35
35
. Fixed bug GH-16572 (Incorrect result with reflection in low-trigger JIT).
36
36
(nielsdos)
37
37
38
+ - OpenSSL:
39
+ . Fix various memory leaks on error conditions in openssl_x509_parse().
40
+ (nielsdos)
41
+
38
42
- PDO:
39
43
. Fixed bug GH-16167 (Prevent mixing PDO sub-classes with different DSN).
40
44
(kocsismate)
Original file line number Diff line number Diff line change @@ -2153,15 +2153,15 @@ PHP_FUNCTION(openssl_x509_parse)
2153
2153
/* Can return NULL on error or memory allocation failure */
2154
2154
if (!bn_serial ) {
2155
2155
php_openssl_store_errors ();
2156
- RETURN_FALSE ;
2156
+ goto err ;
2157
2157
}
2158
2158
2159
2159
hex_serial = BN_bn2hex (bn_serial );
2160
2160
BN_free (bn_serial );
2161
2161
/* Can return NULL on error or memory allocation failure */
2162
2162
if (!hex_serial ) {
2163
2163
php_openssl_store_errors ();
2164
- RETURN_FALSE ;
2164
+ goto err ;
2165
2165
}
2166
2166
2167
2167
str_serial = i2s_ASN1_INTEGER (NULL , asn1_serial );
@@ -2233,19 +2233,15 @@ PHP_FUNCTION(openssl_x509_parse)
2233
2233
bio_out = BIO_new (BIO_s_mem ());
2234
2234
if (bio_out == NULL ) {
2235
2235
php_openssl_store_errors ();
2236
- RETURN_FALSE ;
2236
+ goto err_subitem ;
2237
2237
}
2238
2238
if (nid == NID_subject_alt_name ) {
2239
2239
if (openssl_x509v3_subjectAltName (bio_out , extension ) == 0 ) {
2240
2240
BIO_get_mem_ptr (bio_out , & bio_buf );
2241
2241
add_assoc_stringl (& subitem , extname , bio_buf -> data , bio_buf -> length );
2242
2242
} else {
2243
- zend_array_destroy (Z_ARR_P (return_value ));
2244
2243
BIO_free (bio_out );
2245
- if (cert_str ) {
2246
- X509_free (cert );
2247
- }
2248
- RETURN_FALSE ;
2244
+ goto err_subitem ;
2249
2245
}
2250
2246
}
2251
2247
else if (X509V3_EXT_print (bio_out , extension , 0 , 0 )) {
@@ -2260,6 +2256,16 @@ PHP_FUNCTION(openssl_x509_parse)
2260
2256
if (cert_str ) {
2261
2257
X509_free (cert );
2262
2258
}
2259
+ return ;
2260
+
2261
+ err_subitem :
2262
+ zval_ptr_dtor (& subitem );
2263
+ err :
2264
+ zend_array_destroy (Z_ARR_P (return_value ));
2265
+ if (cert_str ) {
2266
+ X509_free (cert );
2267
+ }
2268
+ RETURN_FALSE ;
2263
2269
}
2264
2270
/* }}} */
2265
2271
You can’t perform that action at this time.
0 commit comments