Bug #74991 [NEW]: include_path has a 4096 char (minus "__DIR__:") limit, in some PHAR cases

From: Date: Wed, 26 Jul 2017 06:02:04 +0000
Subject: Bug #74991 [NEW]: include_path has a 4096 char (minus "__DIR__:") limit, in some PHAR cases
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210339@lists.php.net to get a copy of this message
From: bw at broersma dot com Operating system: Linux PHP version: Irrelevant Package: PHAR related Bug Type: Bug Bug description:include_path has a 4096 char (minus "__DIR__:") limit, in some PHAR cases Description: ------------ include_path has a 4096 char (minus "__DIR__:") limit, in some PHAR cases. I found out by running a phar tool that created long include_paths, and stopped working (https://github.com/civicrm/cv/issues/23). Test script: --------------- --TEST-- include_path has a 4096 char (minus "__DIR__:") limit, in some PHAR cases --SKIPIF-- <?php if (!extension_loaded("phar")) die("skip"); --INI-- phar.readonly=0 --FILE-- <?php // create a sample file in a custom include_path to lookup from the phar later: mkdir('path'); touch('path/needle.php'); $p = new Phar('sample.phar'); // 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: $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');"; $p->setStub("<?php Phar::mapPhar('sample.phar'); __HALT_COMPILER();"); // execute the phar code: require('phar://sample.phar/some/file'); --CLEAN-- <?php unlink('path/needle.php'); unlink('sample.phar'); rmdir('path'); --EXPECT-- Actual result: -------------- Warning: require(needle.php): failed to open stream: No such file or directory in phar:///tests/sample.phar/some/file on line 1 Fatal error: require(): Failed opening required 'needle.php' (include_path='xxxxxxxxx(...) in phar:///tests/sample.phar/some/file on line 1 -- Edit bug report at https://bugs.php.net/bug.php?id=74991&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74991&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74991&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74991&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74991&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74991&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74991&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74991&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74991&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74991&r=support Expected behavior: https://bugs.php.net/fix.php?id=74991&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74991&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74991&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74991&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74991&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74991&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74991&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74991&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74991&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74991&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74991&r=mysqlcfg

« previous php.bugs (#210339) next »