mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix GH-12987: openssl_csr_sign might leak new cert on error
Closes GH-12988
This commit is contained in:
parent
c727f29942
commit
7c4763ab8b
2 changed files with 9 additions and 3 deletions
4
NEWS
4
NEWS
|
@ -25,6 +25,10 @@ PHP NEWS
|
|||
. Added workaround for SELinux mprotect execheap issue.
|
||||
See https://bugzilla.kernel.org/show_bug.cgi?id=218258. (ilutov)
|
||||
|
||||
- OpenSSL:
|
||||
. Fixed bug GH-12987 (openssl_csr_sign might leak new cert on error).
|
||||
(Jakub Zelenka)
|
||||
|
||||
- PDO_ODBC:
|
||||
. Fixed bug GH-12767 (Unable to turn on autocommit mode with setAttribute()).
|
||||
(SakiTakamachi)
|
||||
|
|
|
@ -3154,6 +3154,7 @@ PHP_FUNCTION(openssl_csr_sign)
|
|||
X509 *cert = NULL, *new_cert = NULL;
|
||||
EVP_PKEY * key = NULL, *priv_key = NULL;
|
||||
int i;
|
||||
bool new_cert_used = false;
|
||||
struct php_x509_request req;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_START(4, 6)
|
||||
|
@ -3275,11 +3276,12 @@ PHP_FUNCTION(openssl_csr_sign)
|
|||
object_init_ex(return_value, php_openssl_certificate_ce);
|
||||
cert_object = Z_OPENSSL_CERTIFICATE_P(return_value);
|
||||
cert_object->x509 = new_cert;
|
||||
new_cert_used = true;
|
||||
|
||||
cleanup:
|
||||
|
||||
if (cert == new_cert) {
|
||||
cert = NULL;
|
||||
if (!new_cert_used && new_cert) {
|
||||
X509_free(new_cert);
|
||||
}
|
||||
|
||||
PHP_SSL_REQ_DISPOSE(&req);
|
||||
|
@ -3288,7 +3290,7 @@ cleanup:
|
|||
if (csr_str) {
|
||||
X509_REQ_free(csr);
|
||||
}
|
||||
if (cert_str && cert) {
|
||||
if (cert_str && cert && cert != new_cert) {
|
||||
X509_free(cert);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue