Hi,

I suggest MFH'ing the test for bz2. The problem is that size isn't
initialized at the time when it's passed to buff-compress.

I attached a patch to HEAD, for the PHP_4_0_7 branch I don't have a
patch yet, as I don't have more time currently to test it etc, but it
should be straight forward to adapt it to PHP_4_0_7.

I tested this patch. It makes the test work, and a test on a big file too.

The original intention was and is to not use buff(de)compress but those
stream functions in bzlib, in order to just (de)compress one time, in
stead of retrying all the time, but I didn't yet finish that.

--Jeroen

Jeroen van Wolffelaar
[EMAIL PROTECTED]
http://jeroen.A-Eskwadraat.nl
Index: bz2.c
===================================================================
RCS file: /repository/php4/ext/bz2/bz2.c,v
retrieving revision 1.29
diff -u -r1.29 bz2.c
--- bz2.c       1 Nov 2001 09:45:25 -0000       1.29
+++ bz2.c       13 Nov 2001 10:07:16 -0000
@@ -298,7 +298,8 @@
         * of data + 600 which is the largest size the results of the compression
         * could possibly be, at least that's what the libbz2 docs say (thanks to
         * [EMAIL PROTECTED] for pointing this out).  */
-       dest = emalloc(Z_STRLEN_PP(source) + (0.01 * Z_STRLEN_PP(source)) + 601);
+       size = Z_STRLEN_PP(source) + (0.01 * Z_STRLEN_PP(source)) + 601;
+       dest = emalloc(size);
 
        /* Handle the optional arguments */
        if (ZEND_NUM_ARGS() > 1) {
@@ -318,8 +319,9 @@
                RETURN_FALSE;
        }
 
-       /* size down... */
-       dest = erealloc(dest, size);
+       /* size down... and NUL-terminate */
+       dest = erealloc(dest, size+1);
+       dest[size] = 0;
        RETURN_STRINGL(dest, size, 0);
 }
 /* }}} */
-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to