php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78527 zlib deflate bug with windowBits == 8
Submitted: 2019-09-12 09:43 UTC Modified: 2019-09-13 16:00 UTC
From: wcode404 at gmail dot com Assigned:
Status: Open Package: Zlib related
PHP Version: 7.3.9 OS: linux
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: wcode404 at gmail dot com
New email:
PHP Version: OS:

 

 [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.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Oct 21 08:01:27 2019 UTC