com php-src: Fixed Bug #67724: NEWS ext/zlib/tests/bug67724.gz.gz ext/zlib/tests/bug67724.phpt ext/zlib/zlib_filter.c
| From: | Michael Wallner | Date: | Tue, 05 Aug 2014 13:44:43 +0000 |
| Subject: | com php-src: Fixed Bug #67724: NEWS ext/zlib/tests/bug67724.gz.gz ext/zlib/tests/bug67724.phpt ext/zlib/zlib_filter.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-79733@lists.php.net to get a copy of this message | ||
Commit: e4ff7f2ee346d641715694209e61704c9e815483
Author: Michael Wallner <mike@php.net> Tue, 5 Aug 2014 15:44:43 +0200
Parents: f59506cd271ffb2956cd6948b77d84142df90539
Branches: PHP-5.4 PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e4ff7f2ee346d641715694209e61704c9e815483
Log:
Fixed Bug #67724
(chained zlib filters silently fail with large amounts of data)
Use the same buffer size zlib uses internally to avoid
Z_DATA_ERROR on massively compressed data
Bugs:
https://bugs.php.net/67724
Changed paths:
M NEWS
A ext/zlib/tests/bug67724.gz.gz
A ext/zlib/tests/bug67724.phpt
M ext/zlib/zlib_filter.c
Diff:
diff --git a/NEWS b/NEWS
index a6101e5..d1c06a9 100644
--- a/NEWS
+++ b/NEWS
@@ -40,6 +40,10 @@ PHP NEWS
. Fixed bug #60616 (odbc_fetch_into returns junk data at end of multi-byte
char fields). (Keyur)
+- Zlib:
+ . Fixed bug #67724 (chained zlib filters silently fail with large amounts of
+ data). (Mike)
+
24 Jul 2014, PHP 5.4.31
- Core:
diff --git a/ext/zlib/tests/bug67724.gz.gz b/ext/zlib/tests/bug67724.gz.gz
new file mode 100644
index 0000000..ab1db92
Binary files /dev/null and b/ext/zlib/tests/bug67724.gz.gz differ
diff --git a/ext/zlib/tests/bug67724.phpt b/ext/zlib/tests/bug67724.phpt
new file mode 100644
index 0000000..1e5026f
--- /dev/null
+++ b/ext/zlib/tests/bug67724.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #67724 (chained zlib filters silently fail with large amounts of data)
+--SKIPIF--
+<?php
+extension_loaded("zlib") or die("skip need ext/zlib");
+?>
+--FILE--
+<?php
+echo "Test\n";
+
+$f = fopen(__DIR__."/bug67724.gz.gz", "rb")
+ or die(current(error_get_last()));
+stream_filter_append($f, "zlib.inflate", STREAM_FILTER_READ, ["window" =>
30]);
+stream_filter_append($f, "zlib.inflate", STREAM_FILTER_READ, ["window" =>
30]);
+for ($i = 0; !feof($f); $i += strlen(fread($f, 0x1000)))
+ ;
+fclose($f);
+
+var_dump($i);
+
+?>
+DONE
+--EXPECT--
+Test
+int(25600000)
+DONE
diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c
index 2054ec2..47a68e2 100644
--- a/ext/zlib/zlib_filter.c
+++ b/ext/zlib/zlib_filter.c
@@ -310,7 +310,8 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
data->strm.zalloc = (alloc_func) php_zlib_alloc;
data->strm.zfree = (free_func) php_zlib_free;
- data->strm.avail_out = data->outbuf_len = data->inbuf_len = 2048;
+ data->strm.avail_out = data->outbuf_len = 0x8000;
+ data->inbuf_len = 2048;
data->strm.next_in = data->inbuf = (Bytef *) pemalloc(data->inbuf_len, persistent);
if (!data->inbuf) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes",
data->inbuf_len);