mirror of
https://github.com/php/php-src.git
synced 2024-12-01 05:43:38 +08:00
Better fix for bug #41655
This commit is contained in:
parent
aa54d9e385
commit
506bd484dc
@ -397,19 +397,19 @@ PHP_FUNCTION(glob)
|
||||
#endif
|
||||
|
||||
if (PG(safe_mode) || (PG(open_basedir) && *PG(open_basedir))) {
|
||||
size_t base_len = php_dirname(pattern, strlen(pattern));
|
||||
char pos = pattern[base_len];
|
||||
|
||||
pattern[base_len] = '\0';
|
||||
|
||||
if (PG(safe_mode) && (!php_checkuid(pattern, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
|
||||
int pattern_len = strlen(pattern);
|
||||
char *basename = estrndup(pattern, pattern_len);
|
||||
|
||||
php_dirname(basename, pattern_len);
|
||||
if (PG(safe_mode) && (!php_checkuid(basename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
|
||||
efree(basename);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (php_check_open_basedir(pattern TSRMLS_CC)) {
|
||||
if (php_check_open_basedir(basename TSRMLS_CC)) {
|
||||
efree(basename);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
pattern[base_len] = pos;
|
||||
efree(basename);
|
||||
}
|
||||
|
||||
globbuf.gl_offs = 0;
|
||||
|
@ -7,4 +7,4 @@ open_basedir=/tmp
|
||||
$a=glob("./*.jpeg");
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: glob() [%s]: open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp) in %s on line %d
|
||||
Warning: glob(): open_basedir restriction in effect. File(.) is not within the allowed path(s): (/tmp) in %s on line %d
|
||||
|
Loading…
Reference in New Issue
Block a user