010.phpt 883 B

1234567891011121314151617181920212223242526272829
  1. --TEST--
  2. Phar::mapPhar buffer overrun
  3. --EXTENSIONS--
  4. phar
  5. --INI--
  6. phar.require_hash=0
  7. --FILE--
  8. <?php
  9. $file = "<?php
  10. Phar::mapPhar('hio');
  11. __HALT_COMPILER(); ?>";
  12. // this fails because the manifest length does not include the other 10 byte manifest data
  13. $manifest = pack('V', 1) . 'a' . pack('VVVVVV', 0, time(), 0, crc32(''), 0x00000000, 0);
  14. $file .= pack('VVnVV', strlen($manifest), 1, 0x1000, 0x00000000, 3) . 'hio' . pack('V', 0) . $manifest;
  15. file_put_contents(__DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php', $file);
  16. try {
  17. include __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
  18. echo file_get_contents('phar://hio/a');
  19. } catch (Exception $e) {
  20. echo $e->getMessage();
  21. }
  22. ?>
  23. --CLEAN--
  24. <?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
  25. --EXPECTF--
  26. internal corruption of phar "%s" (too many manifest entries for size of manifest)