summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Beaver <cellog@php.net>2008-01-09 06:45:15 +0000
committerGreg Beaver <cellog@php.net>2008-01-09 06:45:15 +0000
commitad7f030c6d9d9f67f875b3875330029d117c6ea3 (patch)
treeac4d0cabe9e923f20a02eb5ce3a9fa8fb515f042
parent3dd5e7854c75aa3a2f4aa0046a55b9deadbff725 (diff)
downloadphp-git-ad7f030c6d9d9f67f875b3875330029d117c6ea3.tar.gz
fix Bug #43793: zlib filter is unable to auto-detect gzip/zlib file headers
-rw-r--r--NEWS2
-rw-r--r--ext/zlib/tests/zlib_filter_inflate2.phpt41
-rw-r--r--ext/zlib/zlib_filter.c2
3 files changed, 44 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 952d319b66..e84d02d403 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP NEWS
- Fixed a safe_mode bypass in cURL identified by Maksymilian Arciemowicz.
(Ilia)
+- Fixed bug #43793 (zlib filter is unable to auto-detect gzip/zlib file headers).
+ (Greg)
- Fixed bug #43663 (Extending PDO class with a __call() function doesn't work).
(David Soria Parra)
- Fixed bug #43647 (Make FindFile use PATH_SEPARATOR instead of ";"). (Ilia)
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--
+<?php if (!extension_loaded("zlib")) print "skip"; ?>
+--FILE--
+<?php /* $Id$ */
+
+$a = gzopen(dirname(__FILE__) . '/test.txt.gz', 'w');
+fwrite($a, "This is quite the thing ain't it\n");
+fclose($a);
+
+$fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r');
+stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ);
+echo fread($fp, 2000);
+fclose($fp);
+echo "1\n";
+$fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r');
+// zlib format
+$fp = fopen(dirname(__FILE__) . '/test.txt.gz', 'r');
+stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ, array('window' => 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--
+<?php
+@unlink(dirname(__FILE__) . '/test.txt.gz');
+?>
+--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 6460607db9..dc4432f70a 100644
--- a/ext/zlib/zlib_filter.c
+++ b/ext/zlib/zlib_filter.c
@@ -323,7 +323,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);