diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2021-02-16 19:36:37 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2021-02-22 15:28:46 +0100 |
commit | 963e50c8c48ecfbe7444445e5ca8e33530d630d0 (patch) | |
tree | bbd3603cc050f492eddb065e98a37ea3879a46fb /main/streams/streams.c | |
parent | 073b6ea818286fe838097d49f92ae379d5f217f0 (diff) | |
download | php-git-963e50c8c48ecfbe7444445e5ca8e33530d630d0.tar.gz |
Fix #75776: Flushing streams with compression filter is broken
First, the `bzip2.compress` filter has the same issue as `zlib.deflate`
so we port the respective fix[1] to ext/bz2.
Second, there is still an issue, if a stream with an attached
compression filter is flushed before it is closed, without any writes
in between. In that case, the compression is never finalized. We fix
this by enforcing a `_php_stream_flush()` with the `closing` flag set
in `_php_stream_free()`, whenever a write filter is attached. This
call is superfluous for most write filters, but does not hurt, even
when it is unnecessary.
[1] <http://git.php.net/?p=php-src.git;a=commit;h=20e75329f2adb11dd231852c061926d0e4080929>
Closes GH-6703.
Diffstat (limited to 'main/streams/streams.c')
-rw-r--r-- | main/streams/streams.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c index 5f6bf88aa9..c1ecf34623 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -445,7 +445,7 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov (close_options & PHP_STREAM_FREE_RSRC_DTOR) == 0); #endif - if (stream->flags & PHP_STREAM_FLAG_WAS_WRITTEN) { + if (stream->flags & PHP_STREAM_FLAG_WAS_WRITTEN || stream->writefilters.head) { /* make sure everything is saved */ _php_stream_flush(stream, 1); } |