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