From f597e9676b0d4e009241a5b2d21fc9ebf02193a2 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Thu, 25 Jan 2007 12:21:24 +0000 Subject: [PATCH] fix #40189 (possible endless loop in zlib.inflate stream filter) --- ext/bz2/bz2_filter.c | 5 +++++ ext/zlib/zlib_filter.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ext/bz2/bz2_filter.c b/ext/bz2/bz2_filter.c index 5c0010f955..cc42b162a1 100644 --- a/ext/bz2/bz2_filter.c +++ b/ext/bz2/bz2_filter.c @@ -108,6 +108,11 @@ static php_stream_filter_status_t php_bz2_decompress_filter( consumed += desired; bin += desired; + if (!desired) { + flags |= PSFS_FLAG_FLUSH_CLOSE; + break; + } + if (data->strm.avail_out < data->outbuf_len) { php_stream_bucket *out_bucket; size_t bucketlen = data->outbuf_len - data->strm.avail_out; diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c index b24a4c36e4..a292b348e5 100644 --- a/ext/zlib/zlib_filter.c +++ b/ext/zlib/zlib_filter.c @@ -106,6 +106,11 @@ static php_stream_filter_status_t php_zlib_inflate_filter( data->strm.avail_in = 0; bin += desired; + if (!desired) { + flags |= PSFS_FLAG_FLUSH_CLOSE; + break; + } + if (data->strm.avail_out < data->outbuf_len) { php_stream_bucket *out_bucket; size_t bucketlen = data->outbuf_len - data->strm.avail_out; -- 2.50.1