Skip to content

Expand file path in file stat only for wrapper path #12068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions ext/standard/filestat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down