Browse Source

Merge branch 'PHP-5.4' into PHP-5.5

* PHP-5.4:
  fixed glob() edge case on windows, ref bug #47358
  - fix bug #47358, glob returns error, should be empty array()
pull/782/head
Stanislav Malyshev 12 years ago
parent
commit
4185633207
  1. 3
      NEWS
  2. 11
      ext/standard/dir.c
  3. 53
      ext/standard/tests/file/glob_variation3.phpt

3
NEWS

@ -2,6 +2,9 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2014, PHP 5.5.17
- Core:
. Fixed bug #47358 (glob returns error, should be empty array()). (Pierre)
- OpenSSL:
. Fixed bug #41631 (socket timeouts not honored in blocking SSL reads)
(Daniel Lowrey).

11
ext/standard/dir.c

@ -491,13 +491,18 @@ PHP_FUNCTION(glob)
/* now catch the FreeBSD style of "no matches" */
if (!globbuf.gl_pathc || !globbuf.gl_pathv) {
no_results:
#ifndef PHP_WIN32
/* Paths containing '*', '?' and some other chars are
illegal on Windows but legit on other platforms. For
this reason the direct basedir check against the glob
query is senseless on windows. For instance while *.txt
is a pretty valid filename on EXT3, it's invalid on NTFS. */
if (PG(open_basedir) && *PG(open_basedir)) {
struct stat s;
if (0 != VCWD_STAT(pattern, &s) || S_IFDIR != (s.st_mode & S_IFMT)) {
if (php_check_open_basedir_ex(pattern, 0 TSRMLS_CC)) {
RETURN_FALSE;
}
}
#endif
array_init(return_value);
return;
}

53
ext/standard/tests/file/glob_variation3.phpt

@ -6,14 +6,65 @@ $path = dirname(__FILE__);
ini_set('open_basedir', NULL);
var_dump(glob("$path/*.none"));
var_dump(glob("$path/?.none"));
var_dump(glob("$path/*{hello,world}.none"));
var_dump(glob("$path/*/nothere"));
var_dump(glob("$path/[aoeu]*.none"));
var_dump(glob("$path/directly_not_exists"));
ini_set('open_basedir', $path);
var_dump(glob("$path/*.none"));
var_dump(glob("$path/?.none"));
var_dump(glob("$path/*{hello,world}.none"));
var_dump(glob("$path/*/nothere"));
var_dump(glob("$path/[aoeu]*.none"));
var_dump(glob("$path/directly_not_exists"));
ini_set('open_basedir', '/tmp');
var_dump(glob("$path/*.none"));
var_dump(glob("$path/?.none"));
var_dump(glob("$path/*{hello,world}.none"));
var_dump(glob("$path/*/nothere"));
var_dump(glob("$path/[aoeu]*.none"));
var_dump(glob("$path/directly_not_exists"));
?>
==DONE==
--EXPECT--
array(0) {
}
bool(false)
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
array(0) {
}
==DONE==
Loading…
Cancel
Save