File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ PHP NEWS
2525 . Added workaround for SELinux mprotect execheap issue.
2626 See https://bugzilla.kernel.org/show_bug.cgi?id=218258. (ilutov)
2727
28+ - OpenSSL:
29+ . Fixed bug GH-12987 (openssl_csr_sign might leak new cert on error).
30+ (Jakub Zelenka)
31+
2832- PDO_ODBC:
2933 . Fixed bug GH-12767 (Unable to turn on autocommit mode with setAttribute()).
3034 (SakiTakamachi)
Original file line number Diff line number Diff line change @@ -3154,6 +3154,7 @@ PHP_FUNCTION(openssl_csr_sign)
31543154 X509 * cert = NULL , * new_cert = NULL ;
31553155 EVP_PKEY * key = NULL , * priv_key = NULL ;
31563156 int i ;
3157+ bool new_cert_used = false;
31573158 struct php_x509_request req ;
31583159
31593160 ZEND_PARSE_PARAMETERS_START (4 , 6 )
@@ -3275,11 +3276,12 @@ PHP_FUNCTION(openssl_csr_sign)
32753276 object_init_ex (return_value , php_openssl_certificate_ce );
32763277 cert_object = Z_OPENSSL_CERTIFICATE_P (return_value );
32773278 cert_object -> x509 = new_cert ;
3279+ new_cert_used = true;
32783280
32793281cleanup :
32803282
3281- if (cert == new_cert ) {
3282- cert = NULL ;
3283+ if (! new_cert_used && new_cert ) {
3284+ X509_free ( new_cert ) ;
32833285 }
32843286
32853287 PHP_SSL_REQ_DISPOSE (& req );
@@ -3288,7 +3290,7 @@ PHP_FUNCTION(openssl_csr_sign)
32883290 if (csr_str ) {
32893291 X509_REQ_free (csr );
32903292 }
3291- if (cert_str && cert ) {
3293+ if (cert_str && cert && cert != new_cert ) {
32923294 X509_free (cert );
32933295 }
32943296}
You can’t perform that action at this time.
0 commit comments