php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43793 zlib filter is unable to auto-detect gzip/zlib file headers
Submitted: 2008-01-09 06:38 UTC Modified: 2008-01-09 07:09 UTC
From: cellog@php.net Assigned: cellog (profile)
Status: Closed Package: Streams related
PHP Version: 5.2.5 OS: n/a
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cellog@php.net
New email:
PHP Version: OS:

 

 [2008-01-09 06:38 UTC] cellog@php.net
Description:
------------
according to the zlib documentation for inflateInit2() in zlib.h (online copy at http://www.raspberryginger.com/jbailey/minix/html/zlib_8h-source.html):

windowBits can also be greater than 15 for optional gzip decoding. Add
32 to windowBits to enable zlib and gzip decoding with automatic header
detection, or add 16 to decode only the gzip format (the zlib format will return a Z_DATA_ERROR)

zlib.inflate filter's filterparams only accepts window size of 15, but should accept up to 15+32 according to these docs.

Reproduce code:
---------------
<?php /* $Id: zlib_filter_inflate.phpt,v 1.1.2.1 2005/11/24 04:37:47 pollita Exp $ */

$a = gzopen(dirname(__FILE__) . '/test.txt.gz', 'w');
fwrite($a, "This is quite the thing ain't it\n");
fclose($a);

$fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r');
stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ);
echo fread($fp, 2000);
fclose($fp);
echo "1\n";
$fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r');
// zlib format
$fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r');
stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ, array('window' => 15+16));
echo "2\n";
echo fread($fp, 2000);
fclose($fp);
// auto-detect
$fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r');
stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ, array('window' => 15+32));
echo "3\n";
echo fread($fp, 2000);
fclose($fp);

?>


Expected result:
----------------
1
2
This is quite the thing ain't it
3
This is quite the thing ain't it

Actual result:
--------------
1
2
3


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-09 07:09 UTC] cellog@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 11:01:28 2024 UTC