Skip to content

Commit b2157ca

Browse files
committed
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: BFN Fixed Bug #67724
2 parents 3cc2d5d + 442629f commit b2157ca

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

ext/zlib/tests/bug67724.gz.gz

171 Bytes
Binary file not shown.

ext/zlib/tests/bug67724.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #67724 (chained zlib filters silently fail with large amounts of data)
3+
--SKIPIF--
4+
<?php
5+
extension_loaded("zlib") or die("skip need ext/zlib");
6+
?>
7+
--FILE--
8+
<?php
9+
echo "Test\n";
10+
11+
$f = fopen(__DIR__."/bug67724.gz.gz", "rb")
12+
or die(current(error_get_last()));
13+
stream_filter_append($f, "zlib.inflate", STREAM_FILTER_READ, ["window" => 30]);
14+
stream_filter_append($f, "zlib.inflate", STREAM_FILTER_READ, ["window" => 30]);
15+
for ($i = 0; !feof($f); $i += strlen(fread($f, 0x1000)))
16+
;
17+
fclose($f);
18+
19+
var_dump($i);
20+
21+
?>
22+
DONE
23+
--EXPECT--
24+
Test
25+
int(25600000)
26+
DONE

ext/zlib/zlib_filter.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
302302

303303
data->strm.zalloc = (alloc_func) php_zlib_alloc;
304304
data->strm.zfree = (free_func) php_zlib_free;
305-
data->strm.avail_out = data->outbuf_len = data->inbuf_len = 2048;
305+
data->strm.avail_out = data->outbuf_len = 0x8000;
306+
data->inbuf_len = 2048;
306307
data->strm.next_in = data->inbuf = (Bytef *) pemalloc(data->inbuf_len, persistent);
307308
if (!data->inbuf) {
308309
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %zd bytes", data->inbuf_len);

0 commit comments

Comments
 (0)