com php-src: Fix EC_KEY memory leaks: ext/openssl/ope nssl.c
| From: | Jakub Zelenka | Date: | Sun, 30 Oct 2016 18:58:11 +0000 |
| Subject: | com php-src: Fix EC_KEY memory leaks: ext/openssl/ope nssl.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95349@lists.php.net to get a copy of this message | ||
Commit: 72659f95975a2587b7f180c3812fec61518e3cd2
Author: Jakub Zelenka <bukka@php.net> Sun, 30 Oct 2016 18:58:11 +0000
Parents: d23aa74f0782720ae622fa5a9de8d898840eef70
Branches: PHP-7.1
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=72659f95975a2587b7f180c3812fec61518e3cd2
Log:
Fix EC_KEY memory leaks
It was caused by using of EVP_PKEY_get1_EC_KEY which increments an EC_KEY
reference. The fix it we simply use EVP_PKEY_get0_EC_KEY.
Changed paths:
M ext/openssl/openssl.c
Diff:
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index ab58f47..ce9a501 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -4370,7 +4370,7 @@ PHP_FUNCTION(openssl_pkey_export_to_file)
switch (EVP_PKEY_base_id(key)) {
#ifdef HAVE_EVP_PKEY_EC
case EVP_PKEY_EC:
- pem_write = PEM_write_bio_ECPrivateKey(bio_out, EVP_PKEY_get1_EC_KEY(key), cipher, (unsigned
char *)passphrase, (int)passphrase_len, NULL, NULL);
+ pem_write = PEM_write_bio_ECPrivateKey(bio_out, EVP_PKEY_get0_EC_KEY(key), cipher, (unsigned
char *)passphrase, (int)passphrase_len, NULL, NULL);
break;
#endif
default:
@@ -4444,7 +4444,7 @@ PHP_FUNCTION(openssl_pkey_export)
switch (EVP_PKEY_base_id(key)) {
#ifdef HAVE_EVP_PKEY_EC
case EVP_PKEY_EC:
- pem_write = PEM_write_bio_ECPrivateKey(bio_out, EVP_PKEY_get1_EC_KEY(key), cipher, (unsigned
char *)passphrase, (int)passphrase_len, NULL, NULL);
+ pem_write = PEM_write_bio_ECPrivateKey(bio_out, EVP_PKEY_get0_EC_KEY(key), cipher, (unsigned
char *)passphrase, (int)passphrase_len, NULL, NULL);
break;
#endif
default:
@@ -4656,7 +4656,7 @@ PHP_FUNCTION(openssl_pkey_get_details)
ASN1_OBJECT *obj;
// openssl recommends a buffer length of 80
char oir_buf[80];
- const EC_KEY *ec_key = EVP_PKEY_get1_EC_KEY(pkey);
+ const EC_KEY *ec_key = EVP_PKEY_get0_EC_KEY(pkey);
BIGNUM *x = BN_new();
BIGNUM *y = BN_new();
const BIGNUM *d;