php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75273 php_zlib_inflate_filter() may not update bytes_consumed
Submitted: 2017-09-28 09:12 UTC Modified: 2018-09-08 16:42 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: burmartke at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Zlib related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2017-09-28 09:12 UTC] burmartke at gmail dot com
Description:
------------
php_zlib_inflate_filter() fails to update the passed-in bytes_consumed parameter if the last buffer does not produce output, which results in fwrite() returning 0.

It's particularly noticeable if the Debian path "0022-lp564920-fix-big-files.patch" (from eg https://launchpad.net/ubuntu/+archive/primary/+files/php7.0_7.0.22-0ubuntu0.17.04.1.debian.tar.xz) is applied, which disables memory mapping for files > 4MB, as it can cause PharData to throw an exception. See https://github.com/wp-cli/wp-cli/issues/4370#issuecomment-331156677 and https://github.com/wp-cli/wp-cli/issues/4370#issuecomment-331448980 for details.

Test script:
---------------
https://gist.github.com/gitlost/e9895e7687b153c860cddbb1bfec5933

Expected result:
----------------
Nothing.

Actual result:
--------------
bug i=1 out_data_len=32769 fwrite_len=0
bug i=2 out_data_len=32770 fwrite_len=0
bug i=3 out_data_len=32771 fwrite_len=0
bug i=4 out_data_len=32772 fwrite_len=0
bug i=5 out_data_len=32773 fwrite_len=0
bug i=6 out_data_len=32774 fwrite_len=0
bug i=7 out_data_len=32775 fwrite_len=0
bug i=8 out_data_len=32776 fwrite_len=0


Patches

zlib_inflate_filter_bytes_consumed_bug.patch (last revision 2017-09-28 09:13 UTC by burmartke at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-09-08 16:40 UTC] cmb@php.net
-Status: Open +Status: Analyzed -Assigned To: +Assigned To: cmb
 [2018-09-08 16:40 UTC] cmb@php.net
Thanks for forwarding this issue, and for the patch!
 [2018-09-08 16:42 UTC] cmb@php.net
-Summary: php_zlib_inflate_filter() can return 0 bytes_consumed incorrectly +Summary: php_zlib_inflate_filter() may not update bytes_consumed
 [2018-09-08 17:16 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=90d863898cd4d7a1e073916b4730aca33cc29184
Log: Fix #75273: php_zlib_inflate_filter() may not update bytes_consumed
 [2018-09-08 17:16 UTC] cmb@php.net
-Status: Analyzed +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 13 13:01:27 2024 UTC