mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
Expand file path in file stat only for wrapper path (#12068)
This commit is contained in:
parent
1754794fc3
commit
31833e6c4c
@ -727,28 +727,31 @@ PHPAPI void php_stat(zend_string *filename, int type, zval *return_value)
|
||||
|
||||
if (wrapper == &php_plain_files_wrapper) {
|
||||
char realpath[MAXPATHLEN];
|
||||
if (expand_filepath(local, realpath) == NULL) {
|
||||
strlcpy(realpath, local, sizeof(realpath));
|
||||
const char *file_path_to_check;
|
||||
if (strstr(local, "://") == NULL || expand_filepath(local, realpath) == NULL) {
|
||||
file_path_to_check = local;
|
||||
} else {
|
||||
file_path_to_check = realpath;
|
||||
}
|
||||
switch (type) {
|
||||
#ifdef F_OK
|
||||
case FS_EXISTS:
|
||||
RETURN_BOOL(VCWD_ACCESS(realpath, F_OK) == 0);
|
||||
RETURN_BOOL(VCWD_ACCESS(file_path_to_check, F_OK) == 0);
|
||||
break;
|
||||
#endif
|
||||
#ifdef W_OK
|
||||
case FS_IS_W:
|
||||
RETURN_BOOL(VCWD_ACCESS(realpath, W_OK) == 0);
|
||||
RETURN_BOOL(VCWD_ACCESS(file_path_to_check, W_OK) == 0);
|
||||
break;
|
||||
#endif
|
||||
#ifdef R_OK
|
||||
case FS_IS_R:
|
||||
RETURN_BOOL(VCWD_ACCESS(realpath, R_OK) == 0);
|
||||
RETURN_BOOL(VCWD_ACCESS(file_path_to_check, R_OK) == 0);
|
||||
break;
|
||||
#endif
|
||||
#ifdef X_OK
|
||||
case FS_IS_X:
|
||||
RETURN_BOOL(VCWD_ACCESS(realpath, X_OK) == 0);
|
||||
RETURN_BOOL(VCWD_ACCESS(file_path_to_check, X_OK) == 0);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user