From: Antony Dovgal Date: Wed, 31 May 2006 12:06:36 +0000 (+0000) Subject: MFH: fix #37595 (mcrypt_generic calculates data length in wrong way) X-Git-Tag: php-5.2.0RC1~406 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47edd8a303d27afe9ac8f84d0e923c713d294670;p=php MFH: fix #37595 (mcrypt_generic calculates data length in wrong way) --- diff --git a/NEWS b/NEWS index db78febd82..a9c2e616ec 100644 --- a/NEWS +++ b/NEWS @@ -55,6 +55,8 @@ PHP NEWS - 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) diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index 878c883611..a76ae2ee58 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -496,7 +496,7 @@ PHP_FUNCTION(mcrypt_generic) /* 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)); diff --git a/ext/mcrypt/tests/bug37595.phpt b/ext/mcrypt/tests/bug37595.phpt new file mode 100644 index 0000000000..a74b8cfaa8 Binary files /dev/null and b/ext/mcrypt/tests/bug37595.phpt differ