Edit report at https://bugs.php.net/bug.php?id=47358&edit=1
ID: 47358
Updated by: ab@php.net
Reported by: php at guggemand dot dk
Summary: glob returns error, should be empty array()
-Status: Closed
+Status: Re-Opened
Type: Bug
Package: Safe Mode/open_basedir
Operating System: FreeBSD 7.1
PHP Version: 5.2.9RC1
Assigned To: pajoye
Block user comment: N
Private report: N
New Comment:
There are some cases with the platform difference
windows
x64\Debug_TS\php -n -d open_basedir=C:\php-sdk\phpmaster\vc11\x64\php-src -r
"var_dump(glob('C:\php-sdk\phpmaster\vc11\x64\php-src\*.none'));"
bool(false)
x64\Debug_TS\php -n -r
"var_dump(glob('C:\php-sdk\phpmaster\vc11\x64\php-src\*.none'));"
array(0) {
}
linux
sapi/cli/php -n -d open_basedir=/home/anatol/dws/src/php-master-ts -r
'var_dump(glob("/home/anatol/dws/src/php-master-ts/*.none"));'
array(0) {
}
sapi/cli/php -n -r
'var_dump(glob("/home/anatol/dws/src/php-master-ts/*.none"));'
array(0) {
}
The cause of this platform difference is that here
http://lxr.php.net/xref/PHP_TRUNK/ext/standard/dir.c#495
php_check_open_basedir_ex()
subsequently calls virtual_file_ex()
http://lxr.php.net/xref/PHP_TRUNK/TSRM/tsrm_virtual_cwd.c#1241
and if the pattern
contains '*' or '?', php_check_open_basedir_ex() will return -1 on windows.
I've discovered while testing this PR https://github.com/php/php-src/pull/398 which had
the same issue.
Previous Comments:
------------------------------------------------------------------------
[2013-01-08 14:21:58] pajoye@php.net
Automatic comment on behalf of pierre.php@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=50ceeb9f750cecedc483ffc3d3e65a3324e21866
Log: - fix bug #47358, glob returns error, should be empty array()
------------------------------------------------------------------------
[2013-01-08 14:21:57] pajoye@php.net
Automatic comment on behalf of pierre.php@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=2fb7cd30c59345838588ba89ad8b05cc4c34d6dd
Log: - fix bug #47358, glob returns error, should be empty array()
------------------------------------------------------------------------
[2012-11-09 14:09:05] manuel-php at mausz dot at
Hi Pierre!
Please merge your patch asap to php.
It works as expected and will fix the following inconsistency:
$ php -dopen_basedir=/ -r 'var_dump(glob("/does/not/exist"));'
bool(false)
$ php -r 'var_dump(glob("/does/not/exist"));'
array(0) {
}
Something to consider is updating the docs to mention returning false if open_basedir restriction is
in effect.
------------------------------------------------------------------------
[2011-10-09 17:08:22] pajoye@php.net
The following patch has been added/updated:
Patch Name: open_basedir_error_fix
Revision: 1318180102
URL: https://bugs.php.net/patch-display.php?bug=47358&patch=open_basedir_error_fix&revision=1318180102
------------------------------------------------------------------------
[2011-10-09 16:51:14] pajoye@php.net
Please try using this patch (against 5.4 but should work against 5.3). I will
remove the warning too to make it works like the other call (was just to ease the
test).
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=47358--
Edit this bug report at https://bugs.php.net/bug.php?id=47358&edit=1