bug74991.phpt 1.0 KB

123456789101112131415161718192021222324
  1. --TEST--
  2. Phar: PHP bug #74991: include_path has a 4096 char (minus "__DIR__:") limit, in some PHAR cases
  3. --EXTENSIONS--
  4. phar
  5. --INI--
  6. phar.readonly=0
  7. --FILE--
  8. <?php
  9. // create a sample file in a custom include_path to lookup from the phar later:
  10. mkdir('path');
  11. touch('path/needle.php');
  12. $p = new Phar('sample.phar');
  13. // the use of a sub path is crucial, and make the include_path 1 byte larger (=OVERFLOW) than the MAXPATHLEN, the include_path will then be truncated to 4096 (MAXPATHLEN) into 'phar://..sample.phar/some:xx..xx:pat' so it will fail to find needle.php:
  14. $p['some/file'] = "<?php const MAXPATHLEN = 4096, OVERFLOW = 1, PATH = 'path'; set_include_path(str_repeat('x', MAXPATHLEN - strlen(__DIR__ . PATH_SEPARATOR . PATH_SEPARATOR . PATH) + OVERFLOW) . PATH_SEPARATOR . PATH); require('needle.php');";
  15. $p->setStub("<?php Phar::mapPhar('sample.phar'); __HALT_COMPILER();");
  16. // execute the phar code:
  17. require('phar://sample.phar/some/file');
  18. --CLEAN--
  19. <?php
  20. unlink('path/needle.php');
  21. unlink('sample.phar');
  22. rmdir('path');
  23. ?>
  24. --EXPECT--