diff options
author | Stefan Roehrich <sr@php.net> | 2002-03-12 13:06:40 +0000 |
---|---|---|
committer | Stefan Roehrich <sr@php.net> | 2002-03-12 13:06:40 +0000 |
commit | cede952f6a51eb0923e51d22481cd03481c51b9b (patch) | |
tree | eea29775b205505836724a9cb8b6e3075e38e815 | |
parent | f96696e2a158614d98d6165bc47325306bc9ca92 (diff) | |
download | php-git-cede952f6a51eb0923e51d22481cd03481c51b9b.tar.gz |
(PHP gzinflate) Workaround for bug #14939 (buffer error in gzinflate()).
Fixed prototype and added test for #14939.
# We have extra \0 if the input comes directly from gzdeflate()
# so give one extra byte as length to workaround behaviour of zlib.
# I want to avoid copying the input, but if there are problems,
# please tell (see my message <20020310175611.GA4472@stefan.roehri.ch> to
# php-dev).
-rw-r--r-- | ext/zlib/tests/001.phpt | 9 | ||||
-rw-r--r-- | ext/zlib/zlib.c | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/ext/zlib/tests/001.phpt b/ext/zlib/tests/001.phpt index fab6d5dfa3..40b84c6f07 100644 --- a/ext/zlib/tests/001.phpt +++ b/ext/zlib/tests/001.phpt @@ -11,7 +11,16 @@ $packed=gzdeflate($original); echo strlen($packed)." ".strlen($original)."\n"; $unpacked=gzinflate($packed); if (strcmp($original,$unpacked)==0) echo "Strings are equal"; + +echo "\n"; +$original = 'aaaaaaaaaaaaaaa'; +$packed=gzdeflate($original); +echo strlen($packed)." ".strlen($original)."\n"; +$unpacked=gzinflate($packed); +if (strcmp($original,$unpacked)==0) echo "Strings are equal"; ?> --EXPECT-- 100 36864 Strings are equal +5 15 +Strings are equal
\ No newline at end of file diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 6f0f08d298..02889609c7 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -919,7 +919,7 @@ PHP_FUNCTION(gzdeflate) } /* }}} */ -/* {{{ proto string gzinflate(string data, int length) +/* {{{ proto string gzinflate(string data [, int length]) Unzip a gzip-compressed string */ PHP_FUNCTION(gzinflate) { @@ -967,7 +967,7 @@ PHP_FUNCTION(gzinflate) if(! s2) { if(s1) efree(s1); RETURN_FALSE; } stream.next_in = (Bytef*) Z_STRVAL_PP(data); - stream.avail_in = (uInt) Z_STRLEN_PP(data); + stream.avail_in = (uInt) Z_STRLEN_PP(data) + 1; /* there is room for \0 */ stream.next_out = s2; stream.avail_out = (uInt) length; |