Bug #67724 [Ver]: chained zlib filters silently fail with large amounts of data

From: Date: Tue, 05 Aug 2014 08:18:11 +0000
Subject: Bug #67724 [Ver]: chained zlib filters silently fail with large amounts of data
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186975@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67724&edit=1 ID: 67724 Updated by: mike@php.net Reported by: sam at hocevar dot net Summary: chained zlib filters silently fail with large amounts of data Status: Verified Type: Bug Package: Filter related Operating System: Debian GNU/Linux PHP Version: 5.6.0RC2 Assigned To: mike Block user comment: N Private report: N New Comment: The filter apparently doesn't even try to reallocate on Z_MEM_ERROR Previous Comments: ------------------------------------------------------------------------ [2014-08-05 08:15:59] mike@php.net Working memory allocated is probably too less to hold the huge amount which is going to be inflated. ------------------------------------------------------------------------ [2014-07-31 11:59:01] sam at hocevar dot net 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 this bug report at https://bugs.php.net/bug.php?id=67724&edit=1

« previous php.bugs (#186975) next »