From: Antony Dovgal Date: Wed, 31 May 2006 12:04:52 +0000 (+0000) Subject: fix #37595 (mcrypt_generic calculates data length in wrong way) X-Git-Tag: BEFORE_NEW_OUTPUT_API~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4b2d974691096d44ae72e9704cdbe4f54447f21a;p=php fix #37595 (mcrypt_generic calculates data length in wrong way) --- 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