diff options
author | Michael Wallner <mike@php.net> | 2012-03-05 15:35:22 +0000 |
---|---|---|
committer | Michael Wallner <mike@php.net> | 2012-03-05 15:35:22 +0000 |
commit | e63e6647ff84852046cb12f2111fe9bda7eff244 (patch) | |
tree | d5d778df838470b6b26bae6629ca9538a1dd4fe7 | |
parent | 0add0bc021cebfbc08a29dbd983e0ca875e1a707 (diff) | |
download | php-git-e63e6647ff84852046cb12f2111fe9bda7eff244.tar.gz |
fix bug #61287 (A particular string fails to decompress)
-rw-r--r-- | ext/zlib/php_zlib.h | 1 | ||||
-rw-r--r-- | ext/zlib/tests/bug61287.phpt | 24 | ||||
-rw-r--r-- | ext/zlib/zlib.c | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/ext/zlib/php_zlib.h b/ext/zlib/php_zlib.h index c265151abf..3d8c90cbf5 100644 --- a/ext/zlib/php_zlib.h +++ b/ext/zlib/php_zlib.h @@ -65,6 +65,7 @@ extern zend_module_entry php_zlib_module_entry; #define phpext_zlib_ptr zlib_module_ptr #ifdef ZTS +# include "TSRM.h" # define ZLIBG(v) TSRMG(zlib_globals_id, zend_zlib_globals *, v) #else # define ZLIBG(v) (zlib_globals.v) diff --git a/ext/zlib/tests/bug61287.phpt b/ext/zlib/tests/bug61287.phpt new file mode 100644 index 0000000000..769446a8cd --- /dev/null +++ b/ext/zlib/tests/bug61287.phpt @@ -0,0 +1,24 @@ +--TEST-- +bug #61287 - inflate needs the terminating null byte +--SKIPIF-- +<?php extension_loaded("zlib") or die("SKIP need zlib"); +--FILE-- +<?php +$array = array( + 'region_id' => 1, + 'discipline' => 23, + 'degrees' => array(), + 'country_id' => 27 +); + +$serialized = serialize($array); + +$deflated = gzdeflate($serialized, 9); +$inflated = gzinflate($deflated); + +echo strlen($inflated),"\n"; +?> +Done +--EXPECT-- +92 +Done diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 772d8d9c7a..f79dccce51 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -400,7 +400,7 @@ retry_raw_inflate: status = inflateInit2(&Z, encoding); if (Z_OK == status) { Z.next_in = (Bytef *) in_buf; - Z.avail_in = in_len; + Z.avail_in = in_len + 1; /* NOTE: data must be zero terminated */ switch (status = php_zlib_inflate_rounds(&Z, max_len, out_buf, out_len)) { case Z_STREAM_END: |