xref: /PHP-7.4/ext/zip/tests/bug53579.phpt (revision 26dfce7f)
1--TEST--
2Bug #53579 (stream_get_contents() segfaults on ziparchive streams)
3--SKIPIF--
4<?php
5if(!extension_loaded('zip')) die('skip');
6?>
7--FILE--
8<?php
9$dirname = __DIR__ . '/';
10$file = $dirname . 'test_with_comment.zip';
11include $dirname . 'utils.inc';
12$zip = new ZipArchive;
13if (!$zip->open($file)) {
14	exit('failed');
15}
16$fp = $zip->getStream('foo');
17
18var_dump($fp);
19if(!$fp) exit("\n");
20$contents = stream_get_contents($fp);
21
22fclose($fp);
23$zip->close();
24var_dump($contents);
25
26
27$fp = fopen('zip://' . __DIR__ . '/test_with_comment.zip#foo', 'rb');
28if (!$fp) {
29  exit("cannot open\n");
30}
31$contents = stream_get_contents($fp);
32var_dump($contents);
33fclose($fp);
34
35?>
36--EXPECTF--
37resource(%d) of type (stream)
38string(5) "foo
39
40"
41string(5) "foo
42
43"
44