Bug #78527 [Opn]: zlib deflate bug with windowBits == 8
Edit report at https://bugs.php.net/bug.php?id=78527&edit=1
ID: 78527
Updated by: cmb@php.net
Reported by: wcode404 at gmail dot com
Summary: zlib deflate bug with windowBits == 8
Status: Open
Type: Bug
Package: Zlib related
Operating System: linux
PHP Version: 7.3.9
Block user comment: N
Private report: N
New Comment:
In my opinion, this is merely a documentation issue on our part.
Previous Comments:
------------------------------------------------------------------------
[2019-09-12 10:12:59] wcode404 at gmail dot com
Maybe you should give a warning when trying to initialize compression with a window size of 256
bytes and warn that a 512 byte window is actually being created.
Test script:
---------------
$filename = tempnam(sys_get_temp_dir(), 'zlib');
$expected = 'foo';
// write to file the compress content
$context = deflate_init(ZLIB_ENCODING_DEFLATE, ['window' => 8]);
file_put_contents($filename, deflate_add($context, $expected));
// read content from file and uncompress it
$context = inflate_init(ZLIB_ENCODING_DEFLATE, ['window' => 9]);
$actual = inflate_add($context, file_get_contents($filename));
var_dump($expected === $actual);
Actual result:
--------------
bool(true)
------------------------------------------------------------------------
[2019-09-12 09:49:26] nikic@php.net
What is the desired change here, given that zlib does not support this? The current behavior seems
appropriate here.
------------------------------------------------------------------------
[2019-09-12 09:43:34] wcode404 at gmail dot com
Description:
------------
256-byte windows are broken
https://github.com/madler/zlib/issues/171
Test script:
---------------
$filename = tempnam(sys_get_temp_dir(), 'zlib');
$expected = 'foo';
// write to file the compress content
$context = deflate_init(ZLIB_ENCODING_DEFLATE, ['window' => 8]);
file_put_contents($filename, deflate_add($context, $expected));
// read content from file and uncompress it
$context = inflate_init(ZLIB_ENCODING_DEFLATE, ['window' => 8]);
$actual = inflate_add($context, file_get_contents($filename));
var_dump($expected === $actual);
Expected result:
----------------
bool(true)
Actual result:
--------------
inflate_add(): data error
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78527&edit=1
Thread (6 messages)