com php-src: fix unportable dereferencing: ext/openssl/openssl.c

From: Date: Wed, 28 Jan 2015 14:15:38 +0000
Subject: com php-src: fix unportable dereferencing: ext/openssl/openssl.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-84413@lists.php.net to get a copy of this message
Commit: 4d1693744996f78618da768114a2b225fe4fd503 Author: Anatol Belski <ab@php.net> Wed, 28 Jan 2015 15:14:56 +0100 Parents: be29cb15a61a68c2335412661ce1d5025d603100 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4d1693744996f78618da768114a2b225fe4fd503 Log: fix unportable dereferencing Changed paths: M ext/openssl/openssl.c Diff: diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 74d9f0c..1a4c1c3 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -5067,7 +5067,7 @@ PHP_FUNCTION(openssl_digest) } /* }}} */ -static zend_bool php_openssl_validate_iv(char **piv, int *piv_len, int iv_required_len) +static zend_bool php_openssl_validate_iv(char **piv, size_t *piv_len, size_t iv_required_len) { char *iv_new; @@ -5078,7 +5078,7 @@ static zend_bool php_openssl_validate_iv(char **piv, int *piv_len, int iv_requir iv_new = ecalloc(1, iv_required_len + 1); - if (*piv_len <= 0) { + if (*piv_len == 0) { /* BC behavior */ *piv_len = iv_required_len; *piv = iv_new; @@ -5134,10 +5134,10 @@ PHP_FUNCTION(openssl_encrypt) } max_iv_len = EVP_CIPHER_iv_length(cipher_type); - if (iv_len <= 0 && max_iv_len > 0) { + if (iv_len == 0 && max_iv_len > 0) { php_error_docref(NULL, E_WARNING, "Using an empty Initialization Vector (iv) is potentially insecure and not recommended"); } - free_iv = php_openssl_validate_iv(&iv, (int *)&iv_len, max_iv_len); + free_iv = php_openssl_validate_iv(&iv, &iv_len, max_iv_len); outlen = data_len + EVP_CIPHER_block_size(cipher_type); outbuf = zend_string_alloc(outlen, 0); @@ -5230,7 +5230,7 @@ PHP_FUNCTION(openssl_decrypt) key = (unsigned char*)password; } - free_iv = php_openssl_validate_iv(&iv, (int *)&iv_len, EVP_CIPHER_iv_length(cipher_type)); + free_iv = php_openssl_validate_iv(&iv, &iv_len, EVP_CIPHER_iv_length(cipher_type)); outlen = data_len + EVP_CIPHER_block_size(cipher_type); outbuf = zend_string_alloc(outlen, 0);

« previous php.cvs (#84413) next »