xref: /PHP-8.0/ext/phar/tests/tar/links2.phpt (revision f8d79582)
1--TEST--
2Phar: tar with hard link to nowhere
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
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