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