Cygwin: skip native symlink check in Windows dir under WOW64

Commit 456c3a4638 added a workaround when handling paths with native
symlinks as inner path components.  This patch introduced a problem for
paths handled by the WOW64 File System Redirector (FSR).

Fix this problem by not performing the new code from commit 456c3a4638
for paths under the Windows directory.  Only do this in WOW64.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2021-04-21 17:32:06 +02:00
parent 282445a10e
commit 13fd26ecf5
3 changed files with 36 additions and 2 deletions

View File

@ -730,6 +730,12 @@ init_windows_system_directory ()
system_wow64_directory[system_wow64_directory_length++] = L'\\';
system_wow64_directory[system_wow64_directory_length] = L'\0';
}
/* We need the Windows dir in path.cc. */
wcscpy (windows_directory, windows_system_directory);
windows_directory_length = windows_system_directory_length - 1;
windows_directory[windows_directory_length] = L'\0';
while (windows_directory[windows_directory_length - 1] != L'\\')
windows_directory[--windows_directory_length] = L'\0';
#endif /* __i386__ */
}
}

View File

@ -26,6 +26,8 @@ UINT windows_system_directory_length;
#ifdef __i386__
WCHAR system_wow64_directory[MAX_PATH];
UINT system_wow64_directory_length;
WCHAR windows_directory[MAX_PATH];
UINT windows_directory_length;
#endif /* __i386__ */
WCHAR global_progname[NT_MAX_PATH];

View File

@ -3187,9 +3187,31 @@ restart:
forces path_conv::check to backtrack inner path components. */
if (!fs.is_remote_drive ())
{
PFILE_NAME_INFORMATION pfni = (PFILE_NAME_INFORMATION)
tp.c_get ();
#ifdef __i386__
/* On WOW64, ignore any potential problems if the path is inside
the Windows dir to avoid false positives for stuff under
File System Redirector control. */
if (wincap.is_wow64 ())
{
static UNICODE_STRING wpath;
UNICODE_STRING udpath;
/* Create UNICODE_STRING for Windows dir. */
RtlInitCountedUnicodeString (&wpath, windows_directory,
windows_directory_length * sizeof (WCHAR));
/* Create a UNICODE_STRING from incoming path, splitting
off the leading "\\??\\" */
RtlInitCountedUnicodeString (&udpath, upath.Buffer + 4,
upath.Length - 4 * sizeof (WCHAR));
/* Are we below Windows dir? Skip the check for inner
symlinks. */
if (RtlEqualUnicodePathPrefix (&udpath, &wpath, TRUE))
goto skip_inner_syml_check;
}
#endif /* __i386__ */
PFILE_NAME_INFORMATION pfni;
pfni = (PFILE_NAME_INFORMATION) tp.c_get ();
if (NT_SUCCESS (NtQueryInformationFile (h, &io, pfni, NT_MAX_PATH,
FileNameInformation)))
{
@ -3204,6 +3226,10 @@ restart:
break;
}
}
#ifdef __i386__
skip_inner_syml_check:
;
#endif /* __i386__ */
}
}
if (!NT_SUCCESS (status))