diff options
author | Jakub Zelenka <bukka@php.net> | 2017-04-27 15:44:26 +0100 |
---|---|---|
committer | Jakub Zelenka <bukka@php.net> | 2017-04-27 15:44:26 +0100 |
commit | a0b9554f94a47b32e9771b1be999e255ca6bacc7 (patch) | |
tree | 9be540fdba1d401484b0764ce82f804bed5e8fe1 | |
parent | 7b392c7154eb06d8dd19f4e06155b8a4633ac766 (diff) | |
download | php-git-a0b9554f94a47b32e9771b1be999e255ca6bacc7.tar.gz |
Fix possible memory leak in openssl_encrypt and openssl_decrypt
-rw-r--r-- | ext/openssl/openssl.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 1242a80fdb..15b4750537 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); |