summaryrefslogtreecommitdiff
path: root/ext/mcrypt/mcrypt.c
diff options
context:
space:
mode:
authorDerick Rethans <derick@php.net>2007-12-01 17:19:46 +0000
committerDerick Rethans <derick@php.net>2007-12-01 17:19:46 +0000
commit2bb0b237c7b57dd69981047afab6f3c07aa9419f (patch)
tree1c1f9bf7d0d4f239c93f8629e481a3068e5aa5fc /ext/mcrypt/mcrypt.c
parent9f50175611a1772df53143b84b501d9782ed23df (diff)
downloadphp-git-2bb0b237c7b57dd69981047afab6f3c07aa9419f.tar.gz
- Fixed bug #43143 (Warning about empty IV with MCRYPT_MODE_ECB).
Diffstat (limited to 'ext/mcrypt/mcrypt.c')
-rw-r--r--ext/mcrypt/mcrypt.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c
index 0b5b89acd4..0c042c75b3 100644
--- a/ext/mcrypt/mcrypt.c
+++ b/ext/mcrypt/mcrypt.c
@@ -1030,7 +1030,7 @@ int php_mcrypt_func(php_mcrypt_op op, char *cipher, char *mode, char *key_str, i
{
MCRYPT td;
char *cipher_dir_string, *module_dir_string, *key_copy, *iv_copy;
- int i, status = SUCCESS, count, *key_sizes, key_size, iv_size, block_size;
+ int i, status = SUCCESS, count, *key_sizes, key_size, iv_size, block_size, iv_req;
MCRYPT_GET_INI
@@ -1068,6 +1068,7 @@ int php_mcrypt_func(php_mcrypt_op op, char *cipher, char *mode, char *key_str, i
mcrypt_free(key_sizes);
iv_size = mcrypt_enc_get_iv_size(td);
+ iv_req = mcrypt_enc_mode_has_iv(td);
if (iv_len) {
if (iv_len == iv_size) {
iv_copy = estrndup(iv_str, iv_len);
@@ -1077,7 +1078,9 @@ int php_mcrypt_func(php_mcrypt_op op, char *cipher, char *mode, char *key_str, i
memcpy(iv_copy, iv_str, MIN(iv_len, iv_size));
}
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to use an empty IV, which is NOT recommended");
+ if (iv_req) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to use an empty IV, which is NOT recommended");
+ }
iv_copy = ecalloc(1, iv_size);
}