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