File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ PHP NEWS
33
33
. Added workaround for SELinux mprotect execheap issue.
34
34
See https://bugzilla.kernel.org/show_bug.cgi?id=218258. (ilutov)
35
35
36
+ - OpenSSL:
37
+ . Fixed bug GH-12987 (openssl_csr_sign might leak new cert on error).
38
+ (Jakub Zelenka)
39
+
36
40
- PDO_ODBC:
37
41
. Fixed bug GH-12767 (Unable to turn on autocommit mode with setAttribute()).
38
42
(SakiTakamachi)
Original file line number Diff line number Diff line change @@ -3194,6 +3194,7 @@ PHP_FUNCTION(openssl_csr_sign)
3194
3194
X509 * cert = NULL , * new_cert = NULL ;
3195
3195
EVP_PKEY * key = NULL , * priv_key = NULL ;
3196
3196
int i ;
3197
+ bool new_cert_used = false;
3197
3198
struct php_x509_request req ;
3198
3199
3199
3200
ZEND_PARSE_PARAMETERS_START (4 , 6 )
@@ -3315,11 +3316,12 @@ PHP_FUNCTION(openssl_csr_sign)
3315
3316
object_init_ex (return_value , php_openssl_certificate_ce );
3316
3317
cert_object = Z_OPENSSL_CERTIFICATE_P (return_value );
3317
3318
cert_object -> x509 = new_cert ;
3319
+ new_cert_used = true;
3318
3320
3319
3321
cleanup :
3320
3322
3321
- if (cert == new_cert ) {
3322
- cert = NULL ;
3323
+ if (! new_cert_used && new_cert ) {
3324
+ X509_free ( new_cert ) ;
3323
3325
}
3324
3326
3325
3327
PHP_SSL_REQ_DISPOSE (& req );
@@ -3328,7 +3330,7 @@ PHP_FUNCTION(openssl_csr_sign)
3328
3330
if (csr_str ) {
3329
3331
X509_REQ_free (csr );
3330
3332
}
3331
- if (cert_str && cert ) {
3333
+ if (cert_str && cert && cert != new_cert ) {
3332
3334
X509_free (cert );
3333
3335
}
3334
3336
}
You can’t perform that action at this time.
0 commit comments