xref: /PHP-7.3/ext/phar/tests/tar/tar_002.phpt (revision 84488d92)
1--TEST--
2Phar: tar-based phar corrupted 2
3--SKIPIF--
4<?php if (!extension_loaded('phar')) die('skip'); ?>
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9include dirname(__FILE__) . '/files/make_invalid_tar.php.inc';
10
11$tar = new corrupter(dirname(__FILE__) . '/tar_002.phar.tar', 'none');
12$tar->init();
13$tar->addFile('tar_002.phpt', __FILE__);
14$tar->close();
15
16$tar = fopen('phar://' . dirname(__FILE__) . '/tar_002.phar.tar/tar_002.phpt', 'rb');
17
18try {
19	$phar = new Phar(dirname(__FILE__) . '/tar_002.phar.tar');
20	echo "should not execute\n";
21} catch (Exception $e) {
22	echo $e->getMessage() . "\n";
23}
24?>
25===DONE===
26--CLEAN--
27<?php
28@unlink(dirname(__FILE__) . '/tar_002.phar.tar');
29?>
30--EXPECTF--
31Warning: fopen(phar://%star_002.phar.tar/tar_002.phpt): failed to open stream: phar error: "%star_002.phar.tar" is a corrupted tar file (truncated) in %star_002.php on line 9
32phar error: "%star_002.phar.tar" is a corrupted tar file (truncated)
33===DONE===
34