016.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. Phar::mapPhar invalid file (gzipped file length is too short)
  3. --EXTENSIONS--
  4. phar
  5. zlib
  6. --INI--
  7. phar.require_hash=0
  8. --FILE--
  9. <?php
  10. $fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
  11. $pname = 'phar://' . $fname;
  12. $file = "<?php __HALT_COMPILER(); ?>";
  13. // file length is too short
  14. $files = array();
  15. // "hi" gzdeflated
  16. $files['a'] = array('cont'=>'a','comp'=> pack('H*', 'cbc80400'),'flags'=>0x00001000, 'ulen' => 1, 'clen' => 4);
  17. $files['b'] = $files['a'];
  18. $files['c'] = array('cont'=>'*');
  19. $files['d'] = $files['a'];
  20. include 'files/phar_test.inc';
  21. var_dump(file_get_contents($pname . '/a'));
  22. var_dump(file_get_contents($pname . '/b'));
  23. var_dump(file_get_contents($pname . '/c'));
  24. var_dump(file_get_contents($pname . '/d'));
  25. ?>
  26. --CLEAN--
  27. <?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
  28. --EXPECTF--
  29. Warning: 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
  30. bool(false)
  31. Warning: 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
  32. bool(false)
  33. string(1) "*"
  34. Warning: 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
  35. bool(false)