]> granicus.if.org Git - php/commitdiff
Fixed bug #67707 IV not needed for ECB encryption mode, but it returns a warning
authorRobrecht Plaisier <php@mcq8.be>
Fri, 14 Aug 2015 19:16:09 +0000 (19:16 +0000)
committerNikita Popov <nikic@php.net>
Tue, 10 Jan 2017 22:42:44 +0000 (23:42 +0100)
NEWS
ext/mcrypt/mcrypt.c
ext/mcrypt/tests/bug67707.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index d9be2844187f610a2a1ee8b09c589175b6751382..7e0d1ac4325368d69995c8c979dc4d92838db156 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,10 @@ PHP                                                                        NEWS
   . Fixed bug #67583 (double fastcgi_end_request on max_children limit).
     (Dmitry Saprykin)
 
+- MCrypt:
+  . Fixed bug #67707 (IV not needed for ECB encryption mode, but it returns a
+    warning). (Robrecht Plaisier)
+
 - OpenSSL:
   . Fixed bug #71519 (add serial hex to return value array). (xrobau)
 
index b3f681654b2b51dd34d4860785162d9e0ae09868..c589b40fab5f1a127cc6230b9e888cb026d273de 100644 (file)
@@ -572,7 +572,9 @@ PHP_FUNCTION(mcrypt_generic_init)
        memcpy(key_s, key, key_len);
 
        if (iv_len != iv_size) {
-               php_error_docref(NULL, E_WARNING, "Iv size incorrect; supplied length: %zd, needed: %d", iv_len, iv_size);
+               if (mcrypt_enc_mode_has_iv(pm->td)) {
+                       php_error_docref(NULL, E_WARNING, "Iv size incorrect; supplied length: %zd, needed: %d", iv_len, iv_size);
+               }
                if (iv_len > iv_size) {
                        iv_len = iv_size;
                }
diff --git a/ext/mcrypt/tests/bug67707.phpt b/ext/mcrypt/tests/bug67707.phpt
new file mode 100644 (file)
index 0000000..9ba13ab
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+Bug #67707 IV not needed for ECB encryption mode, but it returns a warning
+--SKIPIF--
+<?php if (!extension_loaded("mcrypt")) print "skip"; ?>
+--FILE--
+<?php
+$td = mcrypt_module_open('rijndael-256', '', 'ecb', '');
+mcrypt_generic_init($td, 'secret key', NULL);
+?>
+--EXPECTF--