Annotation of embedaddon/php/ext/zlib/tests/gzinflate-bug42663.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Bug #42663 (gzinflate() try to allocate all memory with truncated $data)
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("zlib")) print "skip"; ?>
! 5: --FILE--
! 6: <?php
! 7: // build a predictable string
! 8: $string = b'';
! 9: for($i=0; $i<30000; ++$i) $string .= (binary)$i . b' ';
! 10: var_dump(strlen($string));
! 11: // deflate string
! 12: $deflated = gzdeflate($string,9);
! 13: var_dump(strlen($deflated));
! 14: // truncate $deflated string
! 15: $truncated = substr($deflated, 0, 65535);
! 16: var_dump(strlen($truncated));
! 17: // inflate $truncated string (check if it will not eat all memory)
! 18: gzinflate($truncated);
! 19: ?>
! 20: --EXPECT--
! 21: int(168890)
! 22: int(66743)
! 23: int(65535)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>