xref: /PHP-7.4/ext/zlib/tests/bug_40189.phpt (revision 26dfce7f)
1--TEST--
2Bug #40189 (endless loop in zlib.inflate stream filter)
3--SKIPIF--
4<?php if (!extension_loaded("zlib")) print "skip"; ?>
5--INI--
6allow_url_fopen=1
7--FILE--
8<?php
9// this string is an excerpt of a phar archive that caused an infinite loop
10$a = "\x3\x0\x85\x46\x2f\x7c\xc2\xaa\x69\x2b\x6d\xe5\xdb\xfe\xe4\x21\x8f\x0\x97\x21\x1d\x2\x0\x0\x0\x47\x42\x4d\x42";
11var_dump(base64_encode($a));
12$gp = fopen(__DIR__ . '/test.other', 'wb');
13$fp = fopen('data://text/plain;base64,AwCFRi98wqppK23l2/7kIY8AlyEdAgAAAEdCTUI=', 'r');
14stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_READ);
15var_dump(stream_copy_to_stream($fp, $gp, 5));
16fclose($fp);
17fclose($gp);
18var_dump(file_get_contents(__DIR__ . '/test.other'));
19?>
20--CLEAN--
21<?php
22@unlink(__DIR__ . '/test.other');
23?>
24--EXPECT--
25string(40) "AwCFRi98wqppK23l2/7kIY8AlyEdAgAAAEdCTUI="
26int(0)
27string(0) ""
28