xref: /PHP-8.3/ext/phar/tests/tar/links2.phpt (revision 74859783)
1--TEST--
2Phar: tar with hard link to nowhere
3--EXTENSIONS--
4phar
5--FILE--
6<?php
7$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.tar';
8$pname = 'phar://' . $fname;
9
10include __DIR__ . '/files/corrupt_tarmaker.php.inc';
11$a = new corrupt_tarmaker($fname, 'none');
12$a->init();
13$a->addFile('hardlink', 'internal/file.txt', array(
14                    'mode' => 0xA000 + 0644,
15                    'uid' => 0,
16                    'gid' => 0,
17                    'size' => 0,
18                    'mtime' => time(),
19                ));
20$a->close();
21
22try {
23    $p = new PharData($fname);
24} catch (Exception $e) {
25    echo $e->getMessage() . "\n";
26}
27?>
28--CLEAN--
29<?php
30unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.tar');
31?>
32--EXPECTF--
33phar error: "%slinks2.tar" is a corrupted tar file - hard link to non-existent file "internal/file.txt"
34