xref: /PHP-5.4/ext/phar/tests/016.phpt (revision 7d114c2e)
1--TEST--
2Phar::mapPhar invalid file (gzipped file length is too short)
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip");?>
5<?php if (!extension_loaded("zlib")) die("skip zlib not present"); ?>
6--INI--
7phar.require_hash=0
8--FILE--
9<?php
10$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
11$pname = 'phar://' . $fname;
12$file = b"<?php __HALT_COMPILER(); ?>";
13// file length is too short
14
15$files = array();
16// "hi" gzdeflated
17$files['a'] = array('cont'=>b'a','comp'=> (binary)pack('H*', 'cbc80400'),'flags'=>0x00001000, 'ulen' => 1, 'clen' => 4);
18$files['b'] = $files['a'];
19$files['c'] = array('cont'=>b'*');
20$files['d'] = $files['a'];
21include 'files/phar_test.inc';
22
23var_dump(file_get_contents($pname . '/a'));
24var_dump(file_get_contents($pname . '/b'));
25var_dump(file_get_contents($pname . '/c'));
26var_dump(file_get_contents($pname . '/d'));
27?>
28--CLEAN--
29<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
30--EXPECTF--
31Warning: file_get_contents(phar://%s/a): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "a") in %s on line %d
32bool(false)
33
34Warning: file_get_contents(phar://%s/b): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "b") in %s on line %d
35bool(false)
36string(1) "*"
37
38Warning: file_get_contents(phar://%s/d): failed to open stream: phar error: internal corruption of phar "%s" (actual filesize mismatch on file "d") in %s on line %d
39bool(false)
40