tony2001 Wed May 31 12:04:53 2006 UTC Added files: /php-src/ext/mcrypt/tests bug37595.phpt
Modified files: /php-src/ext/mcrypt mcrypt.c Log: fix #37595 (mcrypt_generic calculates data length in wrong way) http://cvs.php.net/viewcvs.cgi/php-src/ext/mcrypt/mcrypt.c?r1=1.95&r2=1.96&diff_format=u Index: php-src/ext/mcrypt/mcrypt.c diff -u php-src/ext/mcrypt/mcrypt.c:1.95 php-src/ext/mcrypt/mcrypt.c:1.96 --- php-src/ext/mcrypt/mcrypt.c:1.95 Sun Jan 1 13:09:51 2006 +++ php-src/ext/mcrypt/mcrypt.c Wed May 31 12:04:52 2006 @@ -16,7 +16,7 @@ | Derick Rethans <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ */ -/* $Id: mcrypt.c,v 1.95 2006/01/01 13:09:51 sniper Exp $ */ +/* $Id: mcrypt.c,v 1.96 2006/05/31 12:04:52 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