php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #49411 zlib.inflate stream filter is broken
Submitted: 2009-08-29 21:53 UTC Modified: 2009-11-13 22:36 UTC
From: alex at malexmedia dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.11RC2 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alex at malexmedia dot net
New email:
PHP Version: OS:

 

 [2009-08-29 21:53 UTC] alex at malexmedia dot net
Description:
------------
The ZLib "inflate" stream filter appears to be broken in PHP 5.2.9 and 5.2.10. When trying to inflate a GZip file, or even a stream previously compressed with zlib.deflate, zlib.inflate returns no output.

Reproduce code:
---------------
<?php
//zlibtest.php
//Usage:
//	$ echo TEST TEST TEST | gzip | php zlibtest.php

$input = fopen("php://stdin", "rb");
stream_filter_append($input, 'zlib.inflate', STREAM_FILTER_READ);
while(!feof($input) && ($buffer = fread($input, 8192)) !== FALSE)
	fwrite(STDOUT, $buffer);
fclose($input);

//Inexplicably, this will produce no output on STDOUT.
//Even the example at http://us3.php.net/filters.compression behaves incorrectly.

?>

Expected result:
----------------
I expect to see "TEST TEST TEST" on the command line.

Actual result:
--------------
The zlib.inflate filter is clearly not producing decompressed results on fread() operations. By my reckoning, this is a problem.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-31 16:55 UTC] alex at malexmedia dot net
Just tried the binary windows snapshot (5.2.11RC2-dev) and the problem still appears to be happening.

I'll build the latest snapshot on Linux and try there too...
 [2009-08-31 17:36 UTC] alex at malexmedia dot net
I just built the latest snapshot on Linux and confirmed: this bug is still present on both Linux and Windows.
 [2009-08-31 20:14 UTC] jani@php.net
The examples don't work because someone (Sara) changed the window 
parameter to default to -15 (to widen the range according to the commit 
message) so in the example the deflate uses different params than the 
inflate.

There's also a real bug in this same code. GOTO is truly evil..
 [2009-08-31 20:18 UTC] alex at malexmedia dot net
Let me know when you've got something ready to test, and I'll do so asap. :)
 [2009-08-31 20:41 UTC] jani@php.net
Well, I have a fix for the bug I found but it's actually not related to 
your problem which is just invalid code. As mentioned on the manual page 
you pointed to:

"Note: Compression filters do not generate headers and trailers used by 
command line utilities such as gzip. They only compress and decompress 
the payload portions of compressed data streams."

Hence, your example can not work. This is just documentation issue, 
reclassifying. The invalid example code needs to be fixed. (to use -15 
instead of 15 for window parameter :)
 [2009-08-31 21:04 UTC] alex at malexmedia dot net
I see that. Hmm...

I assumed that my example would work because the bzip2.decompress filter appears to be compatible with the output of the bzip2 command line utility.

So, what would be the "correct" way to perform decompression on an already-opened file stream with GZip data coming in? Any thoughts?
 [2009-11-13 22:36 UTC] vrana@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php

Params are already set in the example.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 20:01:29 2024 UTC