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 @@ -25,6 +25,10 @@ PHP NEWS
25
25
. Added workaround for SELinux mprotect execheap issue.
26
26
See https://bugzilla.kernel.org/show_bug.cgi?id=218258. (ilutov)
27
27
28
+ - OpenSSL:
29
+ . Fixed bug GH-12987 (openssl_csr_sign might leak new cert on error).
30
+ (Jakub Zelenka)
31
+
28
32
- PDO_ODBC:
29
33
. Fixed bug GH-12767 (Unable to turn on autocommit mode with setAttribute()).
30
34
(SakiTakamachi)
Original file line number Diff line number Diff line change @@ -3154,6 +3154,7 @@ PHP_FUNCTION(openssl_csr_sign)
3154
3154
X509 * cert = NULL , * new_cert = NULL ;
3155
3155
EVP_PKEY * key = NULL , * priv_key = NULL ;
3156
3156
int i ;
3157
+ bool new_cert_used = false;
3157
3158
struct php_x509_request req ;
3158
3159
3159
3160
ZEND_PARSE_PARAMETERS_START (4 , 6 )
@@ -3275,11 +3276,12 @@ PHP_FUNCTION(openssl_csr_sign)
3275
3276
object_init_ex (return_value , php_openssl_certificate_ce );
3276
3277
cert_object = Z_OPENSSL_CERTIFICATE_P (return_value );
3277
3278
cert_object -> x509 = new_cert ;
3279
+ new_cert_used = true;
3278
3280
3279
3281
cleanup :
3280
3282
3281
- if (cert == new_cert ) {
3282
- cert = NULL ;
3283
+ if (! new_cert_used && new_cert ) {
3284
+ X509_free ( new_cert ) ;
3283
3285
}
3284
3286
3285
3287
PHP_SSL_REQ_DISPOSE (& req );
@@ -3288,7 +3290,7 @@ PHP_FUNCTION(openssl_csr_sign)
3288
3290
if (csr_str ) {
3289
3291
X509_REQ_free (csr );
3290
3292
}
3291
- if (cert_str && cert ) {
3293
+ if (cert_str && cert && cert != new_cert ) {
3292
3294
X509_free (cert );
3293
3295
}
3294
3296
}
You can’t perform that action at this time.
0 commit comments