summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2016-10-12 23:19:07 -0700
committerAnatol Belski <ab@php.net>2016-10-13 09:43:59 +0200
commit48f61377519d8dc4b3ad8127af69df41b46469d9 (patch)
tree2a87c2d39f42807c91de2e4c8f03fd8382440236
parent7d014f4bd0e48378d3f5bd1f21e0cb37c93612de (diff)
downloadphp-git-48f61377519d8dc4b3ad8127af69df41b46469d9.tar.gz
Fix outlen for openssl function
Even though datalen can't be over int, outlen can. (cherry picked from commit cd8c9b06149dc7dc0415524f1d74880fd6f2d25c)
-rw-r--r--ext/openssl/openssl.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index 648b110d61..6bf1d6b25f 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -5303,7 +5303,8 @@ PHP_FUNCTION(openssl_encrypt)
size_t data_len, method_len, password_len, iv_len = 0, max_iv_len;
const EVP_CIPHER *cipher_type;
EVP_CIPHER_CTX cipher_ctx;
- int i=0, outlen, keylen;
+ int i=0, keylen;
+ size_t outlen;
zend_string *outbuf;
unsigned char *key;
zend_bool free_iv;
@@ -5334,7 +5335,7 @@ PHP_FUNCTION(openssl_encrypt)
}
free_iv = php_openssl_validate_iv(&iv, &iv_len, max_iv_len);
- outlen = (int)data_len + EVP_CIPHER_block_size(cipher_type);
+ outlen = data_len + EVP_CIPHER_block_size(cipher_type);
outbuf = zend_string_alloc(outlen, 0);
EVP_EncryptInit(&cipher_ctx, cipher_type, NULL, NULL);
@@ -5386,7 +5387,8 @@ PHP_FUNCTION(openssl_decrypt)
size_t data_len, method_len, password_len, iv_len = 0;
const EVP_CIPHER *cipher_type;
EVP_CIPHER_CTX cipher_ctx;
- int i, outlen, keylen;
+ int i, keylen;
+ size_t outlen;
zend_string *outbuf;
unsigned char *key;
zend_string *base64_str = NULL;
@@ -5410,7 +5412,7 @@ PHP_FUNCTION(openssl_decrypt)
}
if (!(options & OPENSSL_RAW_DATA)) {
- base64_str = php_base64_decode((unsigned char*)data, (int)data_len);
+ base64_str = php_base64_decode((unsigned char*)data, data_len);
if (!base64_str) {
php_error_docref(NULL, E_WARNING, "Failed to base64 decode the input");
RETURN_FALSE;
@@ -5430,7 +5432,7 @@ PHP_FUNCTION(openssl_decrypt)
free_iv = php_openssl_validate_iv(&iv, &iv_len, EVP_CIPHER_iv_length(cipher_type));
- outlen = (int)data_len + EVP_CIPHER_block_size(cipher_type);
+ outlen = data_len + EVP_CIPHER_block_size(cipher_type);
outbuf = zend_string_alloc(outlen, 0);
EVP_DecryptInit(&cipher_ctx, cipher_type, NULL, NULL);