com php-src: Fix possible memory leak in openssl_encrypt an d openssl_decrypt: ext/openssl/openssl.c
| From: | Jakub Zelenka | Date: | Thu, 27 Apr 2017 14:44:26 +0000 |
| Subject: | com php-src: Fix possible memory leak in openssl_encrypt an d openssl_decrypt: ext/openssl/openssl.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-97722@lists.php.net to get a copy of this message | ||
Commit: a0b9554f94a47b32e9771b1be999e255ca6bacc7
Author: Jakub Zelenka <bukka@php.net> Thu, 27 Apr 2017 15:44:26 +0100
Parents: 7b392c7154eb06d8dd19f4e06155b8a4633ac766
Branches: PHP-7.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a0b9554f94a47b32e9771b1be999e255ca6bacc7
Log:
Fix possible memory leak in openssl_encrypt and openssl_decrypt
Changed paths:
M ext/openssl/openssl.c
Diff:
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index 1242a80..15b4750 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -5699,6 +5699,7 @@ PHP_FUNCTION(openssl_encrypt)
}
PHP_OPENSSL_CHECK_SIZE_T_TO_INT(data_len, data);
+ PHP_OPENSSL_CHECK_SIZE_T_TO_INT(password_len, password);
cipher_ctx = EVP_CIPHER_CTX_new();
if (!cipher_ctx) {
@@ -5726,7 +5727,6 @@ PHP_FUNCTION(openssl_encrypt)
EVP_EncryptInit(cipher_ctx, cipher_type, NULL, NULL);
if (password_len > keylen) {
- PHP_OPENSSL_CHECK_SIZE_T_TO_INT(password_len, password);
EVP_CIPHER_CTX_set_key_length(cipher_ctx, (int)password_len);
}
EVP_EncryptInit_ex(cipher_ctx, NULL, NULL, key, (unsigned char *)iv);
@@ -5790,6 +5790,7 @@ PHP_FUNCTION(openssl_decrypt)
}
PHP_OPENSSL_CHECK_SIZE_T_TO_INT(data_len, data);
+ PHP_OPENSSL_CHECK_SIZE_T_TO_INT(password_len, password);
cipher_type = EVP_get_cipherbyname(method);
if (!cipher_type) {
@@ -5830,7 +5831,6 @@ PHP_FUNCTION(openssl_decrypt)
EVP_DecryptInit(cipher_ctx, cipher_type, NULL, NULL);
if (password_len > keylen) {
- PHP_OPENSSL_CHECK_SIZE_T_TO_INT(password_len, password);
EVP_CIPHER_CTX_set_key_length(cipher_ctx, (int)password_len);
}
EVP_DecryptInit_ex(cipher_ctx, NULL, NULL, key, (unsigned char *)iv);