xref: /PHP-7.2/ext/phar/tests/bug69720.phpt (revision f1d7e3ca)
1--TEST--
2Phar - bug #69720 - Null pointer dereference in phar_get_fp_offset()
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--FILE--
6<?php
7try {
8    // open an existing phar
9    $p = new Phar(__DIR__."/bug69720.phar",0);
10    // Phar extends SPL's DirectoryIterator class
11	echo $p->getMetadata();
12    foreach (new RecursiveIteratorIterator($p) as $file) {
13        // $file is a PharFileInfo class, and inherits from SplFileInfo
14	$temp="";
15        $temp= $file->getFileName() . "\n";
16        $temp.=file_get_contents($file->getPathName()) . "\n"; // display contents
17	var_dump($file->getMetadata());
18    }
19}
20 catch (Exception $e) {
21    echo 'Could not open Phar: ', $e;
22}
23?>
24--EXPECTF--
25MY_METADATA_NULL
26
27Warning: file_get_contents(phar://%s): failed to open stream: phar error: "test.php" is not a file in phar "%s.phar" in %s.php on line %d
28array(1) {
29  ["whatever"]=>
30  int(123)
31}
32object(DateTime)#2 (3) {
33  ["date"]=>
34  string(26) "2000-01-01 00:00:00.000000"
35  ["timezone_type"]=>
36  int(3)
37  ["timezone"]=>
38  string(3) "UTC"
39}
40