Bug #67724 [NEW]: chained zlib filters silently fail with large amounts of data
| From: | sam at hocevar dot net | Date: | Thu, 31 Jul 2014 11:59:02 +0000 |
| Subject: | Bug #67724 [NEW]: chained zlib filters silently fail with large amounts of data | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186904@lists.php.net to get a copy of this message | ||
From: sam at hocevar dot net
Operating system: Debian GNU/Linux
PHP version: 5.6.0RC2
Package: Filter related
Bug Type: Bug
Bug description:chained zlib filters silently fail with large amounts of data
Description:
------------
The
zlib.inflate filter silently fails in some circumstances.
The attached test case creates highly compressed files, then reads them
in chunks of 4 KiB with two chained zlib.inflate filters. When the
original data is larger than 25 MB, something breaks and I have no idea
what or why.
Test script:
---------------
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
/* Create a doubly-gzipped file, then read it back using zlib filters
* and report how many KiB were decompressed. */
function create_and_read($f, $kb)
{
system("dd count=$kb bs=1024 </dev/zero 2>/dev/null | gzip | gzip >|
$f");
$in = fopen($f, 'rb');
$out = 0;
$args = array('window' => 30);
stream_filter_prepend($in, 'zlib.inflate', STREAM_FILTER_READ,
$args);
stream_filter_prepend($in, 'zlib.inflate', STREAM_FILTER_READ,
$args);
while (!feof($in))
$out += strlen(fread($in, 4096));
unlink($f);
print "in: $kb KiB\tout: " . $out / 1024 . " KiB\n";
}
foreach (array(10, 100, 10000, 24800, 24801, 100000) as $kb)
create_and_read('/tmp/x', $kb);
Expected result:
----------------
in: 10 KiB out: 10 KiB
in: 100 KiB out: 100 KiB
in: 10000 KiB out: 10000 KiB
in: 24800 KiB out: 24800 KiB
in: 24801 KiB out: 24801 KiB
in: 100000 KiB out: 100000 KiB
Actual result:
--------------
in: 10 KiB out: 10 KiB
in: 100 KiB out: 100 KiB
in: 10000 KiB out: 10000 KiB
in: 24800 KiB out: 24800 KiB
in: 24801 KiB out: 0 KiB
in: 100000 KiB out: 0 KiB
--
Edit bug report at https://bugs.php.net/bug.php?id=67724&edit=1
--