Skip to content

Commit f44d53b

Browse files
committed
Merge branch 'PHP-7.3'
* PHP-7.3: Fixed bug #77317 __DIR__, __FILE__, realpath() reveal physical path for subst virtual drive
2 parents 95d8e05 + 199914b commit f44d53b

File tree

1 file changed

+0
-54
lines changed

1 file changed

+0
-54
lines changed

Zend/zend_virtual_cwd.c

-54
Original file line numberDiff line numberDiff line change
@@ -957,40 +957,6 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim
957957
}
958958
/* }}} */
959959

960-
#ifdef ZEND_WIN32
961-
static size_t tsrm_win32_realpath_quick(char *path, size_t len, time_t *t) /* {{{ */
962-
{
963-
char tmp_resolved_path[MAXPATHLEN];
964-
int tmp_resolved_path_len;
965-
BY_HANDLE_FILE_INFORMATION info;
966-
realpath_cache_bucket *bucket;
967-
968-
if (!*t) {
969-
*t = time(0);
970-
}
971-
972-
if (CWDG(realpath_cache_size_limit) && (bucket = realpath_cache_find(path, len, *t)) != NULL) {
973-
memcpy(path, bucket->realpath, bucket->realpath_len + 1);
974-
return bucket->realpath_len;
975-
}
976-
977-
if (!php_win32_ioutil_realpath_ex0(path, tmp_resolved_path, &info)) {
978-
DWORD err = GetLastError();
979-
SET_ERRNO_FROM_WIN32_CODE(err);
980-
return (size_t)-1;
981-
}
982-
983-
tmp_resolved_path_len = strlen(tmp_resolved_path);
984-
if (CWDG(realpath_cache_size_limit)) {
985-
realpath_cache_add(path, len, tmp_resolved_path, tmp_resolved_path_len, info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY, *t);
986-
}
987-
memmove(path, tmp_resolved_path, tmp_resolved_path_len + 1);
988-
989-
return tmp_resolved_path_len;
990-
}
991-
/* }}} */
992-
#endif
993-
994960
/* Resolve path relatively to state and put the real path into state */
995961
/* returns 0 for ok, 1 for error */
996962
CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func verify_path, int use_realpath) /* {{{ */
@@ -1118,27 +1084,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func
11181084

11191085
add_slash = (use_realpath != CWD_REALPATH) && path_length > 0 && IS_SLASH(resolved_path[path_length-1]);
11201086
t = CWDG(realpath_cache_ttl) ? 0 : -1;
1121-
#ifdef ZEND_WIN32
1122-
if (CWD_EXPAND != use_realpath) {
1123-
size_t tmp_len = tsrm_win32_realpath_quick(resolved_path, path_length, &t);
1124-
if ((size_t)-1 != tmp_len) {
1125-
path_length = tmp_len;
1126-
} else {
1127-
DWORD err = GetLastError();
1128-
/* The access denied error can mean something completely else,
1129-
fallback to complicated way. */
1130-
if (CWD_REALPATH == use_realpath && ERROR_ACCESS_DENIED != err) {
1131-
SET_ERRNO_FROM_WIN32_CODE(err);
1132-
return 1;
1133-
}
1134-
path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, &t, use_realpath, 0, NULL);
1135-
}
1136-
} else {
1137-
path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, &t, use_realpath, 0, NULL);
1138-
}
1139-
#else
11401087
path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, &t, use_realpath, 0, NULL);
1141-
#endif
11421088

11431089
if (path_length == (size_t)-1) {
11441090
errno = ENOENT;

0 commit comments

Comments
 (0)