From: Greg Beaver Date: Wed, 9 Jan 2008 06:42:56 +0000 (+0000) Subject: fix Bug #43793: zlib filter is unable to auto-detect gzip/zlib file headers X-Git-Tag: RELEASE_2_0_0a1~974 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7cda2c40a663cbb9aed0cda3e55b44327f5d1dd3;p=php fix Bug #43793: zlib filter is unable to auto-detect gzip/zlib file headers --- diff --git a/ext/zlib/tests/zlib_filter_inflate2.phpt b/ext/zlib/tests/zlib_filter_inflate2.phpt new file mode 100644 index 0000000000..4332d8e5e6 --- /dev/null +++ b/ext/zlib/tests/zlib_filter_inflate2.phpt @@ -0,0 +1,41 @@ +--TEST-- +zlib.inflate of gzip-encoded stream +--SKIPIF-- + +--FILE-- + 15+16)); +echo "2\n"; +echo fread($fp, 2000); +fclose($fp); +// auto-detect +$fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r'); +stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ, array('window' => 15+32)); +echo "3\n"; +echo fread($fp, 2000); +fclose($fp); + +?> +--CLEAN-- + +--EXPECT-- +1 +2 +This is quite the thing ain't it +3 +This is quite the thing ain't it \ No newline at end of file diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c index cf753e85f2..46eb30b0ed 100644 --- a/ext/zlib/zlib_filter.c +++ b/ext/zlib/zlib_filter.c @@ -335,7 +335,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f /* log-2 base of history window (9 - 15) */ SEPARATE_ZVAL(tmpzval); convert_to_long_ex(tmpzval); - if (Z_LVAL_PP(tmpzval) < -MAX_WBITS || Z_LVAL_PP(tmpzval) > MAX_WBITS) { + if (Z_LVAL_PP(tmpzval) < -MAX_WBITS || Z_LVAL_PP(tmpzval) > MAX_WBITS + 32) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter give for window size. (%ld)", Z_LVAL_PP(tmpzval)); } else { windowBits = Z_LVAL_PP(tmpzval);