Skip to content

Commit

Permalink
MFH: Fixed bug #61287 (A particular string fails to decompress)
Browse files Browse the repository at this point in the history
  • Loading branch information
m6w6 committed Mar 5, 2012
1 parent f05886d commit 39d2996
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -61,6 +61,7 @@ PHP NEWS

- Zlib:
. Fixed bug #61139 (gzopen leaks when specifying invalid mode). (Nikita Popov)
. Fixed bug #61287 (A particular string fails to decompress). (Mike)

01 Mar 2012, PHP 5.4.0

Expand Down
1 change: 1 addition & 0 deletions ext/zlib/php_zlib.h
Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions 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
2 changes: 1 addition & 1 deletion ext/zlib/zlib.c
Expand Up @@ -400,7 +400,7 @@ static int php_zlib_decode(const char *in_buf, size_t in_len, char **out_buf, si
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:
Expand Down

0 comments on commit 39d2996

Please sign in to comment.