]> granicus.if.org Git - php/commitdiff
MFH: fix #37595 (mcrypt_generic calculates data length in wrong way)
authorAntony Dovgal <tony2001@php.net>
Wed, 31 May 2006 12:06:36 +0000 (12:06 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 31 May 2006 12:06:36 +0000 (12:06 +0000)
NEWS
ext/mcrypt/mcrypt.c
ext/mcrypt/tests/bug37595.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index db78febd82747a51657ed91cf0197c1673030268..a9c2e616ec2f796b0bfdad6e8b6f96a6cf1ae2ed 100644 (file)
--- 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)
index 878c883611d46fc4d96574d7377c07a36fd61ea5..a76ae2ee58a23bc7598baa1cc4115951d1da821a 100644 (file)
@@ -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 (file)
index 0000000..a74b8cf
Binary files /dev/null and b/ext/mcrypt/tests/bug37595.phpt differ