Bug #78527 [Opn]: zlib deflate bug with windowBits == 8

From: Date: Fri, 13 Sep 2019 11:14:47 +0000
Subject: Bug #78527 [Opn]: zlib deflate bug with windowBits == 8
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222728@lists.php.net to get a copy of this message
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)

« previous php.bugs (#222728) next »