From: Antony Dovgal Date: Thu, 25 Jan 2007 12:21:24 +0000 (+0000) Subject: fix #40189 (possible endless loop in zlib.inflate stream filter) X-Git-Tag: RELEASE_1_0_0RC1~135 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f597e9676b0d4e009241a5b2d21fc9ebf02193a2;p=php fix #40189 (possible endless loop in zlib.inflate stream filter) --- 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;