PHP :: Bug #61423 :: gzip compression fails

Bug #61423 gzip compression fails
Submitted: 2012-03-17 02:01 UTC Modified: 2012-04-12 23:24 UTC
Votes:44
Avg. Score:4.9 ± 0.4
Reproduced:41 of 43 (95.3%)
Same Version:19 (46.3%)
Same OS:38 (92.7%)
From: borrible13th at gmx dot net Assigned: iliaa (profile)
Status: Closed Package: SOAP related
PHP Version: 5.4.0 OS: ALL
Private report: No CVE-ID: None

 [2012-03-17 02:01 UTC] borrible13th at gmx dot net

Description:
------------
SOAP fails to compress with gzip encoding (compression level greater 0): it warns 
"encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or 
ZLIB_ENCODING_DEFLATE" and throws SoapFault with "SoapClient::__doRequest() 
returned non string value".

Cause: Zlib introduces new constants ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, 
ZLIB_ENCODING_DEFLATE and redefines FORCE_GZIP as ZLIB_ENCODING_GZIP and 
FORCE_DEFLATE as ZLIB_ENCODING_DEFLATE.

In php_http.c, line 263ff. the call to gzencode is prepared with an hard coded 
magic number (1) for the gzip encoding: gzencode(data, level, 1).
It should be gzencode(data, level, FORCE_GZIP) or gzencode(data, level, 
ZLIB_ENCODING_GZIP), because the magic number is now defined as 0x1f (31).

Test script:
---------------
new SoapClient($wsdl, array('soap_version' => SOAP_1_2, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 1 ));

Expected result:
----------------
Call gzencode(data, level, FORCE_GZIP) (or gzencode(data, level, 
ZLIB_ENCODING_GZIP)), so it returns compressed data.

Actual result:
--------------
gzencode(data, level, 1) is called, so it returns always false and warns "encoding 
mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or 
ZLIB_ENCODING_DEFLATE".

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports

 [2012-03-18 15:15 UTC] iliaa@php.net

-Status: Open +Status: Closed -Assigned To: +Assigned To: iliaa

 [2012-03-19 12:36 UTC] borrible13th at gmx dot net

Can't see a bugfix in the source code whether in the branch for 5.4 or in the 
trunk! The magic number (1) is still hard coded.
Do I miss something?

 [2012-03-20 00:16 UTC] borrible13th at gmx dot net

-Status: Closed +Status: Assigned

 [2012-03-20 00:16 UTC] borrible13th at gmx dot net

Changed status to "Assigned" due to last comment.

 [2012-03-22 13:54 UTC] iliaa@php.net

This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

There was an issue with the fix push, all good now.

 [2012-03-22 13:54 UTC] iliaa@php.net

-Status: Assigned +Status: Closed

 [2012-03-22 15:52 UTC] borrible13th at gmx dot net

This bug is PHP 5.4 only, and not PHP 5.3! So, applying the bugfix on branch PHP-5.3 is totally wrong! 

Zlib introduces new constants ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, 
ZLIB_ENCODING_DEFLATE in PHP 5.4 and redefines the older constants of PHP 5.3 and older (FORCE_GZIP as ZLIB_ENCODING_GZIP and FORCE_DEFLATE as ZLIB_ENCODING_DEFLATE).

Sorry for changing status again.

---
Overview of constants in ext/zlib/php_zlib.h:

PHP 5.3:
  CODING_GZIP 1 (registered as "FORCE_GZIP")
  CODING_DEFLATE 2 (registered as "FORCE_DEFLATE")

PHP 5.4:
  PHP_ZLIB_ENCODING_RAW -0xf
    (registered as "ZLIB_ENCODING_RAW")
  PHP_ZLIB_ENCODING_GZIP 0x1f (31)
    (registered as "ZLIB_ENCODING_GZIP" and "FORCE_GZIP")
  PHP_ZLIB_ENCODING_DEFLATE 0x0f (15)
    (registered as "ZLIB_ENCODING_DEFLATE" and "FORCE_DEFLATE")
  [PHP_ZLIB_ENCODING_ANY 0x2f (47)]

 [2012-03-22 15:52 UTC] borrible13th at gmx dot net

-Status: Closed +Status: Assigned

 [2012-03-24 16:28 UTC] iliaa@php.net

-Status: Assigned +Status: Closed

 [2012-03-26 13:28 UTC] borrible13th at gmx dot net

-Status: Closed +Status: Assigned

 [2012-03-26 13:28 UTC] borrible13th at gmx dot net

"Merge branch 'PHP-5.3' into PHP-5.4" (7a1c765385) reverted this bugfix! :(
Please re-commit it to branch PHP-5.4 only. Thanks in advance!

 [2012-04-12 23:24 UTC] borrible13th at gmx dot net

Please cherry-pick commit 9c5ae99 into branch 5.4.1. The bugfix is still missing 
there, although the bug is listed as fixed in https://github.com/php/php-
src/blob/PHP-5.4.1/NEWS#L85 (line 85).

 [2012-06-01 00:02 UTC] borrible13th at gmx dot net

What's the current status?

 [2014-10-07 23:27 UTC] stas@php.net

-Status: Assigned +Status: Closed