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