]> granicus.if.org Git - php/commitdiff
- Fixed bug #47179 (gzuncompress does not report expcted error)
authorJani Taskinen <jani@php.net>
Wed, 9 Dec 2009 20:33:31 +0000 (20:33 +0000)
committerJani Taskinen <jani@php.net>
Wed, 9 Dec 2009 20:33:31 +0000 (20:33 +0000)
ext/zlib/tests/gzuncompress_error1.phpt
ext/zlib/zlib.c

index 8f9a42969f1a24d3bf63d3d08990d7d31892a847..99c419314d07eba373869b83f69873832464137d 100644 (file)
@@ -1,7 +1,5 @@
 --TEST--
 Test gzuncompress() function : error conditions 
---XFAIL--
-Test will fail until bug #47179 resolved; no error when $length too small 
 --SKIPIF--
 <?php 
 if (!extension_loaded("zlib")) {
@@ -16,8 +14,6 @@ if (!extension_loaded("zlib")) {
  * Alias to functions: 
  */
 
-
-
 echo "*** Testing gzuncompress() : error conditions ***\n";
 
 // Zero arguments
@@ -34,14 +30,12 @@ var_dump( gzuncompress($data, $length, $extra_arg) );
 echo "\n-- Testing with Unicode string --\n";
 var_dump(gzuncompress($data, $length));
 
-
 echo "\n-- Testing with a buffer that is too small --\n";
 $short_len = strlen($data) - 1;
 $compressed = gzcompress(b"$data");
 
 var_dump(gzuncompress($compressed, $short_len));
 
-
 echo "\n-- Testing with incorrect arguments --\n";
 var_dump(gzuncompress(123));
 
@@ -77,7 +71,8 @@ Warning: gzuncompress() expects parameter 1 to be strictly a binary string, Unic
 NULL
 
 -- Testing with a buffer that is too small --
-Warning: gzuncompress(): buffer error in %s on line %d
+
+Warning: gzuncompress(): insufficient memory in %s on line %d
 bool(false)
 
 -- Testing with incorrect arguments --
@@ -90,4 +85,4 @@ NULL
 
 Warning: gzuncompress() expects parameter 2 to be long, Unicode string given in %s on line %d
 NULL
-===DONE===
\ No newline at end of file
+===DONE===
index 1a77f022cff1067f229fafb6729b69bf2cbb1a3a..b62e71bb3dc343ee81e25c5e4132c803bfb5a0fb 100644 (file)
@@ -321,10 +321,10 @@ static inline int php_zlib_inflate_rounds(z_stream *Z, size_t max, char **buf, s
        *buf = NULL;
        *len = 0;
 
-       buffer.size = Z->avail_in;
+       buffer.size = (max && (max < Z->avail_in)) ? max : Z->avail_in;
 
        do {
-               if ((max && (max < buffer.used)) || !(buffer.aptr = erealloc_recoverable(buffer.data, buffer.size))) {
+               if ((max && (max <= buffer.used)) || !(buffer.aptr = erealloc_recoverable(buffer.data, buffer.size))) {
                        status = Z_MEM_ERROR;
                } else {
                        buffer.data = buffer.aptr;