tony2001 Wed May 31 12:06:36 2006 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/mcrypt/tests bug37595.phpt
Modified files:
/php-src NEWS
/php-src/ext/mcrypt mcrypt.c
Log:
MFH: fix #37595 (mcrypt_generic calculates data length in wrong way)
http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2027.2.547.2.67&r2=1.2027.2.547.2.68&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.67 php-src/NEWS:1.2027.2.547.2.68
--- php-src/NEWS:1.2027.2.547.2.67 Wed May 31 03:43:17 2006
+++ php-src/NEWS Wed May 31 12:06:36 2006
@@ -55,6 +55,8 @@
- Fixed bug #37616 (DATE_RFC822 does not product RFC 822 dates).
(Hannes Magnusson, Derick)
- Fixed bug #37614 (Class name lowercased in error message). (Johannes)
+- Fixed bug #37595 (mcrypt_generic calculates data length in wrong way).
+ (Tony)
- Fixed bug #37587 (var without attribute causes segfault). (Marcus)
- Fixed bug #37586 (Bumped minimum PCRE version to 6.6, needed for recursion
limit support). (Ilia)
http://cvs.php.net/viewcvs.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.91.2.3.2.1&r2=1.91.2.3.2.2&diff_format=u
Index: php-src/ext/mcrypt/mcrypt.c
diff -u php-src/ext/mcrypt/mcrypt.c:1.91.2.3.2.1
php-src/ext/mcrypt/mcrypt.c:1.91.2.3.2.2
--- php-src/ext/mcrypt/mcrypt.c:1.91.2.3.2.1 Thu May 11 08:06:22 2006
+++ php-src/ext/mcrypt/mcrypt.c Wed May 31 12:06:36 2006
@@ -16,7 +16,7 @@
| Derick Rethans <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: mcrypt.c,v 1.91.2.3.2.1 2006/05/11 08:06:22 helly Exp $ */
+/* $Id: mcrypt.c,v 1.91.2.3.2.2 2006/05/31 12:06:36 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -496,7 +496,7 @@
/* Check blocksize */
if (mcrypt_enc_is_block_mode(pm->td) == 1) { /* It's a block algorithm
*/
block_size = mcrypt_enc_get_block_size(pm->td);
- data_size = (((Z_STRLEN_PP(data) - 1) / block_size) + 1) *
block_size;
+ data_size = ((Z_STRLEN_PP(data) / block_size) + 1) * block_size;
data_s = emalloc(data_size + 1);
memset(data_s, 0, data_size);
memcpy(data_s, Z_STRVAL_PP(data), Z_STRLEN_PP(data));
http://cvs.php.net/viewcvs.cgi/php-src/ext/mcrypt/tests/bug37595.phpt?view=markup&rev=1.1
Index: php-src/ext/mcrypt/tests/bug37595.phpt
+++ php-src/ext/mcrypt/tests/bug37595.phpt
--TEST--
bug #37595 (mcrypt_generic calculates data length in wrong way)
--FILE--
<?php
$cipher_alg = MCRYPT_BLOWFISH;
$skey = array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
$key='';
foreach($skey as $t) {
$key .= chr($t);
}
$sstr = array(1,2,3,4,5,6,7,8);
$iv='';
foreach($sstr as $s) {
$iv .= chr($s);
}
$str = "12345678";
$td = mcrypt_module_open(MCRYPT_BLOWFISH,'',MCRYPT_MODE_CBC,'');
$data = Array(
'12345678',
'123456789',
"\x001234567",
'',
'1234567812345678',
'12345678123456789'
);
foreach ($data as $val) {
mcrypt_generic_init($td, $key, $iv);
$enc = mcrypt_generic($td, $val);
mcrypt_generic_deinit($td);
mcrypt_generic_init($td, $key, $iv);
var_dump($dec = mdecrypt_generic($td, $enc));
}
mcrypt_module_close($td);
echo "Done\n";
?>
--EXPECT--
string(16) "12345678
string(16) "123456789
string(16) "
string(8) "
string(24) "1234567812345678
string(24) "12345678123456789
Done
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php