php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75807 deflate_init fails with window bits set to 8
Submitted: 2018-01-12 02:09 UTC Modified: 2020-11-20 11:19 UTC
From: matt at bonneau dot net Assigned: cmb (profile)
Status: Closed Package: Zlib related
PHP Version: master-Git-2018-01-12 (Git) OS:
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: matt at bonneau dot net
New email:
PHP Version: OS:

 

 [2018-01-12 02:09 UTC] matt at bonneau dot net
Description:
------------
Newer versions of zlib reject an 8 bit window. Minimum value should be changed to 9 instead of 8. This failure was noticed with zlib 1.2.8.

Test script:
---------------
<?php
deflate_init(
    ZLIB_ENCODING_RAW,
    [
        'window'   => 8,
    ]
);

Expected result:
----------------
Expect no output.

Actual result:
--------------
Warning: deflate_init(): failed allocating zlib.deflate context in test3.php on line 5

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-12 02:22 UTC] matt at bonneau dot net
Output should actually be:
Warning: deflate_init(): zlib window size (logarithm) (8) must be within 9..15
 [2018-01-12 02:25 UTC] matt at bonneau dot net
See: https://github.com/madler/zlib/commit/049578f0a1849f502834167e233f4c1d52ddcbcc

"There is a bug in deflate for windowBits == 8 (256-byte window).
As a result, zlib silently changes a request for 8 to a request
for 9 (512-byte window), and sets the zlib header accordingly so
that the decompressor knows to use a 512-byte window. However if
deflateInit2() is used for raw deflate or gzip streams, then there
is no indication that the request was not honored, and the
application might assume that it can use a 256-byte window when
decompressing. This commit returns an error if the user requests
a 256-byte window when using raw deflate or gzip encoding."
 [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
-Status: Closed +Status: Open -Type: Bug +Type: Documentation Problem -Assigned To: +Assigned To: cmb
 [2020-11-20 11:18 UTC] cmb@php.net
This is more of a documentation issue; at least window size 8 is
still supported for ZLIB_ENCODING_DEFLATE.
 [2020-11-20 11:19 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [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-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 Apr 23 07:01:29 2024 UTC