Bug #74991 [Opn->Csd]: include_path has a 4096 char (minus "__DIR__:") limit, in some PHAR cases
| From: | krakjoe@php.net | Date: | Wed, 26 Jul 2017 09:48:43 +0000 |
| Subject: | Bug #74991 [Opn->Csd]: include_path has a 4096 char (minus "__DIR__:") limit, in some PHAR cases | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210341@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74991&edit=1
ID: 74991
Updated by: krakjoe@php.net
Reported by: bw at broersma dot com
Summary: include_path has a 4096 char (minus "__DIR__:")
limit, in some PHAR cases
-Status: Open
+Status: Closed
Type: Bug
Package: PHAR related
Operating System: Linux
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of bw@broersma.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6b1fbafdf0590ec293968d38c78641283b119848
Log: Fix bug #74991 - include_path has a 4096 char (minus "__DIR__:") limit, in
some PHAR cases
Previous Comments:
------------------------------------------------------------------------
[2017-07-26 06:01:55] bw at broersma dot com
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 this bug report at https://bugs.php.net/bug.php?id=74991&edit=1