File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ PHP NEWS
92
92
(cmb)
93
93
. Fixed bug GH-16433 (Large values for openssl_csr_sign() $days overflow).
94
94
(cmb)
95
+ . Fix various memory leaks on error conditions in openssl_x509_parse().
96
+ (nielsdos)
95
97
96
98
- PDO_ODBC:
97
99
. Fixed bug GH-16450 (PDO_ODBC can inject garbage into field values). (cmb)
Original file line number Diff line number Diff line change @@ -2131,15 +2131,15 @@ PHP_FUNCTION(openssl_x509_parse)
2131
2131
/* Can return NULL on error or memory allocation failure */
2132
2132
if (!bn_serial ) {
2133
2133
php_openssl_store_errors ();
2134
- RETURN_FALSE ;
2134
+ goto err ;
2135
2135
}
2136
2136
2137
2137
hex_serial = BN_bn2hex (bn_serial );
2138
2138
BN_free (bn_serial );
2139
2139
/* Can return NULL on error or memory allocation failure */
2140
2140
if (!hex_serial ) {
2141
2141
php_openssl_store_errors ();
2142
- RETURN_FALSE ;
2142
+ goto err ;
2143
2143
}
2144
2144
2145
2145
str_serial = i2s_ASN1_INTEGER (NULL , asn1_serial );
@@ -2211,19 +2211,15 @@ PHP_FUNCTION(openssl_x509_parse)
2211
2211
bio_out = BIO_new (BIO_s_mem ());
2212
2212
if (bio_out == NULL ) {
2213
2213
php_openssl_store_errors ();
2214
- RETURN_FALSE ;
2214
+ goto err_subitem ;
2215
2215
}
2216
2216
if (nid == NID_subject_alt_name ) {
2217
2217
if (openssl_x509v3_subjectAltName (bio_out , extension ) == 0 ) {
2218
2218
BIO_get_mem_ptr (bio_out , & bio_buf );
2219
2219
add_assoc_stringl (& subitem , extname , bio_buf -> data , bio_buf -> length );
2220
2220
} else {
2221
- zend_array_destroy (Z_ARR_P (return_value ));
2222
2221
BIO_free (bio_out );
2223
- if (cert_str ) {
2224
- X509_free (cert );
2225
- }
2226
- RETURN_FALSE ;
2222
+ goto err_subitem ;
2227
2223
}
2228
2224
}
2229
2225
else if (X509V3_EXT_print (bio_out , extension , 0 , 0 )) {
@@ -2238,6 +2234,16 @@ PHP_FUNCTION(openssl_x509_parse)
2238
2234
if (cert_str ) {
2239
2235
X509_free (cert );
2240
2236
}
2237
+ return ;
2238
+
2239
+ err_subitem :
2240
+ zval_ptr_dtor (& subitem );
2241
+ err :
2242
+ zend_array_destroy (Z_ARR_P (return_value ));
2243
+ if (cert_str ) {
2244
+ X509_free (cert );
2245
+ }
2246
+ RETURN_FALSE ;
2241
2247
}
2242
2248
/* }}} */
2243
2249
You can’t perform that action at this time.
0 commit comments