com php-src: Fix bug #74991 - include_path has a 40 96 char (minus "__DIR__:") limit , in some PHAR cases: NEWS ext/phar/tests/bug 74991.phpt
ext/phar/util.c

From: Date: Wed, 26 Jul 2017 09:46:50 +0000
Subject: com php-src: Fix bug #74991 - include_path has a 40 96 char (minus "__DIR__:") limit , in some PHAR cases: NEWS ext/phar/tests/bug 74991.phpt
ext/phar/util.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-98811@lists.php.net to get a copy of this message
Commit: 6b1fbafdf0590ec293968d38c78641283b119848 Author: Benjamin W.. Broersma <bw@broersma.com> Wed, 26 Jul 2017 08:16:37 +0200 Committer: Joe Watkins <krakjoe@php.net> Wed, 26 Jul 2017 10:46:50 +0100 Parents: de65a2243f5e52ccafc69889ab0b64f4481c5358 Branches: PHP-7.0 PHP-7.1 PHP-7.2 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6b1fbafdf0590ec293968d38c78641283b119848 Log: Fix bug #74991 - include_path has a 4096 char (minus "__DIR__:") limit, in some PHAR cases Bugs: https://bugs.php.net/74991 Changed paths: M NEWS A ext/phar/tests/bug74991.phpt M ext/phar/util.c Diff: diff --git a/NEWS b/NEWS index 8e41ef0..d91c6c9 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,10 @@ PHP NEWS - OCI8: . Expose oci_unregister_taf_callback() (Tianfang Yang) +- phar: + . Fixed bug #74991 (include_path has a 4096 char limit in some cases). + (bwbroersma) + - SimpleXML: . Fixed bug #74950 (nullpointer deref in simplexml_element_getDocNamespaces). (Laruence) diff --git a/ext/phar/tests/bug74991.phpt b/ext/phar/tests/bug74991.phpt new file mode 100644 index 0000000..88d47be --- /dev/null +++ b/ext/phar/tests/bug74991.phpt @@ -0,0 +1,23 @@ +--TEST-- +Phar: PHP bug #74991: 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-- diff --git a/ext/phar/util.c b/ext/phar/util.c index f571429..54ff13b 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -316,7 +316,7 @@ splitted: efree(test); } - spprintf(&path, MAXPATHLEN, "phar://%s/%s%c%s", arch, PHAR_G(cwd), DEFAULT_DIR_SEPARATOR, PG(include_path)); + spprintf(&path, MAXPATHLEN + 1 + strlen(PG(include_path)), "phar://%s/%s%c%s", arch, PHAR_G(cwd), DEFAULT_DIR_SEPARATOR, PG(include_path)); efree(arch); ret = php_resolve_path(filename, filename_len, path); efree(path);

« previous php.cvs (#98811) next »