Edit report at https://bugs.php.net/bug.php?id=48725&edit=1
ID: 48725
Updated by: cmb@php.net
Reported by: slusarz at curecanti dot org
Summary: Support for flushing in zlib stream
-Status: Verified
+Status: Closed
Type: Bug
Package: Streams related
Operating System: Linux
PHP Version: 5.2.10
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=20e75329f2adb11dd231852c061926d0e4080929
Log: Fix #48725: Support for flushing in zlib stream
Previous Comments:
------------------------------------------------------------------------
[2020-08-19 16:30:43] cmb@php.net
The following pull request has been associated:
Patch Name: Fix #48725: Support for flushing in zlib stream
On GitHub: https://github.com/php/php-src/pull/6019
Patch: https://github.com/php/php-src/pull/6019.patch
------------------------------------------------------------------------
[2020-08-19 10:47:30] cmb@php.net
The reproducer provided by @arnout doesn't seem to be related,
since it apparently has the same root cause as bug #77069.
------------------------------------------------------------------------
[2012-11-02 17:13:29] nastasi at alternativeoutput dot it
I had worked on the php source code and found a fix.
To understand what happens I had traced what happens during a
....
for ($i = 0 ; $i < 3 ; $i++) {
fwrite($s[0]);
fread($s[1]);
fflush($s[0]);
fread($s[1]);
}
loop and I found that the deflate function is never called with the
Z_SYNC_FLUSH flag set because no new data are present into the backets_in
brigade.
My fix is to manage the PSFS_FLAG_FLUSH_INC case AND no iterations are
performed on deflate function extending the
if (flags & PSFS_FLAG_FLUSH_CLOSE) {
managing FLUSH_INC too:
if (flags & PSFS_FLAG_FLUSH_CLOSE || (flags & PSFS_FLAG_FLUSH_INC &&
to_be_flushed)) {
All my work is performed on Debian squeeze 6.0.5, and PHP 5.3.3-7+squeeze14 but I already check the
current git version and it seems not changed for the essetial parts.
------------------------------------------------------------------------
[2012-10-24 13:27:35] arnout dot boks at moxio dot com
Verified this with PHP 5.4.7 on Windows.
Another reproduce case:
-----------------------
<?php
$stream = fopen('data://text/plain;base64,' . base64_encode('Foo bar baz'),
'r');
stream_filter_append($stream, 'zlib.deflate', STREAM_FILTER_READ);
print bin2hex(stream_get_contents($stream));
Expected:
---------
73cbcf57484a2c02e22a00 // == bin2hex(gzdeflate('Foo bar baz'))
Actual:
-------
// (empty)
Variations tried:
-----------------
- Replacing the 'zlib.deflate'-filter by another stream filter ('string.rot13')
gives the correct output.
- Replacing the 'data://'-URL by a 'file://'- or 'http://'-URL pointing to the
same data gives the correct output.
- Replacing the 'data://'-URL by a 'php://memory' or 'php://temp'
stream to
which the data has been written (and the stream rewinded) gives empty output
------------------------------------------------------------------------
[2012-05-20 01:45:27] lello-3 at hotmail dot com
Please fix this
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=48725
--
Edit this bug report at https://bugs.php.net/bug.php?id=48725&edit=1