File tree 2 files changed +16
-8
lines changed 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,8 @@ PHP NEWS
86
86
(cmb)
87
87
. Fixed bug GH-16433 (Large values for openssl_csr_sign() $days overflow).
88
88
(cmb)
89
+ . Fix various memory leaks on error conditions in openssl_x509_parse().
90
+ (nielsdos)
89
91
90
92
- PDO_ODBC:
91
93
. Fixed bug GH-16450 (PDO_ODBC can inject garbage into field values). (cmb)
Original file line number Diff line number Diff line change @@ -2091,15 +2091,15 @@ PHP_FUNCTION(openssl_x509_parse)
2091
2091
/* Can return NULL on error or memory allocation failure */
2092
2092
if (!bn_serial ) {
2093
2093
php_openssl_store_errors ();
2094
- RETURN_FALSE ;
2094
+ goto err ;
2095
2095
}
2096
2096
2097
2097
hex_serial = BN_bn2hex (bn_serial );
2098
2098
BN_free (bn_serial );
2099
2099
/* Can return NULL on error or memory allocation failure */
2100
2100
if (!hex_serial ) {
2101
2101
php_openssl_store_errors ();
2102
- RETURN_FALSE ;
2102
+ goto err ;
2103
2103
}
2104
2104
2105
2105
str_serial = i2s_ASN1_INTEGER (NULL , asn1_serial );
@@ -2171,19 +2171,15 @@ PHP_FUNCTION(openssl_x509_parse)
2171
2171
bio_out = BIO_new (BIO_s_mem ());
2172
2172
if (bio_out == NULL ) {
2173
2173
php_openssl_store_errors ();
2174
- RETURN_FALSE ;
2174
+ goto err_subitem ;
2175
2175
}
2176
2176
if (nid == NID_subject_alt_name ) {
2177
2177
if (openssl_x509v3_subjectAltName (bio_out , extension ) == 0 ) {
2178
2178
BIO_get_mem_ptr (bio_out , & bio_buf );
2179
2179
add_assoc_stringl (& subitem , extname , bio_buf -> data , bio_buf -> length );
2180
2180
} else {
2181
- zend_array_destroy (Z_ARR_P (return_value ));
2182
2181
BIO_free (bio_out );
2183
- if (cert_str ) {
2184
- X509_free (cert );
2185
- }
2186
- RETURN_FALSE ;
2182
+ goto err_subitem ;
2187
2183
}
2188
2184
}
2189
2185
else if (X509V3_EXT_print (bio_out , extension , 0 , 0 )) {
@@ -2198,6 +2194,16 @@ PHP_FUNCTION(openssl_x509_parse)
2198
2194
if (cert_str ) {
2199
2195
X509_free (cert );
2200
2196
}
2197
+ return ;
2198
+
2199
+ err_subitem :
2200
+ zval_ptr_dtor (& subitem );
2201
+ err :
2202
+ zend_array_destroy (Z_ARR_P (return_value ));
2203
+ if (cert_str ) {
2204
+ X509_free (cert );
2205
+ }
2206
+ RETURN_FALSE ;
2201
2207
}
2202
2208
/* }}} */
2203
2209
You can’t perform that action at this time.
0 commit comments