- Fixed possible crash in ext/soap because of uninitialized value. (Zdash Urf)
+- Fixed bug #43143 (Warning about empty IV with MCRYPT_MODE_ECB). (Derick)
- Fixed bug #43136 (possible crash on script execution timeout.
The EG(function_state_ptr) is completely removed,
EG(current_execute_data)->function_state must be used instead). (Dmitry)
{
char *cipher_dir_string;
char *module_dir_string;
- int block_size, max_key_length, use_key_length, i, count, iv_size;
+ int block_size, max_key_length, use_key_length, i, count, iv_size, req_iv;
unsigned long int data_size;
int *key_length_sizes;
char *key_s = NULL, *iv_s;
/* Check IV */
iv_s = NULL;
iv_size = mcrypt_enc_get_iv_size (td);
+ req_iv = mcrypt_enc_mode_has_iv(td);
if (argc == 5) {
if (iv_size != Z_STRLEN_PP(iv)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, MCRYPT_IV_WRONG_SIZE);
memcpy(iv_s, Z_STRVAL_PP(iv), iv_size);
}
} else if (argc == 4) {
- if (iv_size != 0) {
+ if (req_iv == 1) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to use an empty IV, which is NOT recommend");
iv_s = emalloc(iv_size + 1);
memset(iv_s, 0, iv_size + 1);
--- /dev/null
+--TEST--
+Bug #43143 (Warning about empty IV with MCRYPT_MODE_ECB)
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+echo "ECB\n";
+$input = 'to be encrypted';
+$mkey = hash('sha256', 'secret key', TRUE);
+$data = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $mkey, $input, MCRYPT_MODE_ECB);
+echo "CFB\n";
+$input = 'to be encrypted';
+$mkey = hash('sha256', 'secret key', TRUE);
+$data = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $mkey, $input, MCRYPT_MODE_CFB);
+echo "END\n";
+?>
+--EXPECTF--
+ECB
+CFB
+
+Warning: mcrypt_encrypt(): Attempt to use an empty IV, which is NOT recommend in %sbug43143.php on line 9
+END