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 @@ -86,6 +86,8 @@ PHP NEWS
8686 (cmb)
8787 . Fixed bug GH-16433 (Large values for openssl_csr_sign() $days overflow).
8888 (cmb)
89+ . Fix various memory leaks on error conditions in openssl_x509_parse().
90+ (nielsdos)
8991
9092- PDO_ODBC:
9193 . 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)
20912091 /* Can return NULL on error or memory allocation failure */
20922092 if (!bn_serial ) {
20932093 php_openssl_store_errors ();
2094- RETURN_FALSE ;
2094+ goto err ;
20952095 }
20962096
20972097 hex_serial = BN_bn2hex (bn_serial );
20982098 BN_free (bn_serial );
20992099 /* Can return NULL on error or memory allocation failure */
21002100 if (!hex_serial ) {
21012101 php_openssl_store_errors ();
2102- RETURN_FALSE ;
2102+ goto err ;
21032103 }
21042104
21052105 str_serial = i2s_ASN1_INTEGER (NULL , asn1_serial );
@@ -2171,19 +2171,15 @@ PHP_FUNCTION(openssl_x509_parse)
21712171 bio_out = BIO_new (BIO_s_mem ());
21722172 if (bio_out == NULL ) {
21732173 php_openssl_store_errors ();
2174- RETURN_FALSE ;
2174+ goto err_subitem ;
21752175 }
21762176 if (nid == NID_subject_alt_name ) {
21772177 if (openssl_x509v3_subjectAltName (bio_out , extension ) == 0 ) {
21782178 BIO_get_mem_ptr (bio_out , & bio_buf );
21792179 add_assoc_stringl (& subitem , extname , bio_buf -> data , bio_buf -> length );
21802180 } else {
2181- zend_array_destroy (Z_ARR_P (return_value ));
21822181 BIO_free (bio_out );
2183- if (cert_str ) {
2184- X509_free (cert );
2185- }
2186- RETURN_FALSE ;
2182+ goto err_subitem ;
21872183 }
21882184 }
21892185 else if (X509V3_EXT_print (bio_out , extension , 0 , 0 )) {
@@ -2198,6 +2194,16 @@ PHP_FUNCTION(openssl_x509_parse)
21982194 if (cert_str ) {
21992195 X509_free (cert );
22002196 }
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 ;
22012207}
22022208/* }}} */
22032209
You can’t perform that action at this time.
0 commit comments