php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #78527 zlib deflate bug with windowBits == 8
Submitted: 2019-09-12 09:43 UTC Modified: 2020-12-10 12:58 UTC
From: wcode404 at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Zlib related
PHP Version: 7.3.9 OS: linux
Private report: No CVE-ID: None
 [2019-09-12 09:43 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-12 09:49 UTC] nikic@php.net
-Status: Open +Status: Feedback
 [2019-09-12 09:49 UTC] 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 10:12 UTC] wcode404 at gmail dot com
-Status: Feedback +Status: Open
 [2019-09-12 10:12 UTC] 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-13 11:14 UTC] cmb@php.net
In my opinion, this is merely a documentation issue on our part.
 [2019-09-13 16:00 UTC] wcode404 at gmail dot com
I agree. It will be great if you document this bug.
 [2020-11-20 11:18 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=5c818901d4f95ed211ecb3d476472cec1c739979
Log: Fix #78527: zlib deflate bug with windowBits == 8 Fix #75807: deflate_init fails with window bits set to 8
 [2020-11-20 11:18 UTC] phpdocbot@php.net
-Status: Open +Status: Closed
 [2020-11-20 11:18 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-11-20 20:10 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=c877fdbb2a207480e1cafa8f915d32c4cd9e7b6f
Log: Fix #78527: zlib deflate bug with windowBits == 8 Fix #75807: deflate_init fails with window bits set to 8
 [2020-12-10 12:58 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem
 [2020-12-30 11:58 UTC] nikic@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=e5838751cf7145874e9eccff69ad29855af2af20
Log: Fix #78527: zlib deflate bug with windowBits == 8 Fix #75807: deflate_init fails with window bits set to 8
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 06:01:30 2024 UTC