summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-09-22 16:02:01 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-12-08 11:47:49 +0100
commit65f5573bc82108bbaf2727ffa11575f3292d736f (patch)
tree6dc2ff7610878ca2d1518d33da67e73ee6951af1 /main
parentbd093ad8615267ae4ff1a237e6285dc182a9ff57 (diff)
downloadphp-git-65f5573bc82108bbaf2727ffa11575f3292d736f.tar.gz
Fix #77069: stream filter loses final block of data
Reading from a stream may return greater than zero, but nonetheless the stream's EOF flag may have been set. We have to cater to this condition by setting the close flag for filters. We also have to cater to that change in the zlib.inflate filter: If `inflate()` is called with flush mode `Z_FINISH`, but the output buffer is not large enough to inflate all available data, it fails with `Z_BUF_ERROR`. However, `Z_BUF_ERROR` is not fatal; in fact, the zlib manual states: "If deflate returns with Z_OK or Z_BUF_ERROR, this function must be called again with Z_FINISH and more output space (updated avail_out) but no more input data, until it returns with Z_STREAM_END or an error." Hence, we do so. Closes GH-6001.
Diffstat (limited to 'main')
-rw-r--r--main/streams/streams.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/main/streams/streams.c b/main/streams/streams.c
index cf411a1dd3..ab413872e0 100644
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -567,7 +567,7 @@ PHPAPI int _php_stream_fill_read_buffer(php_stream *stream, size_t size)
/* after this call, bucket is owned by the brigade */
php_stream_bucket_append(brig_inp, bucket);
- flags = PSFS_FLAG_NORMAL;
+ flags = stream->eof ? PSFS_FLAG_FLUSH_CLOSE : PSFS_FLAG_NORMAL;
} else {
flags = stream->eof ? PSFS_FLAG_FLUSH_CLOSE : PSFS_FLAG_FLUSH_INC;
}