Cygwin: path: Fix UNC path handling for SMB3 mounted to a drive.

- If an UNC path is mounted to a drive using SMB3.11, accessing to
  the drive fails with error "Too many levels of symbolic links."
  This patch fixes the issue.
This commit is contained in:
Takashi Yano 2022-02-03 12:00:14 +09:00
parent 4a70041dfd
commit e5aca9ced9
1 changed files with 11 additions and 2 deletions

View File

@ -3495,10 +3495,19 @@ restart:
/* If incoming path has no trailing backslash, but final path /* If incoming path has no trailing backslash, but final path
has one, drop trailing backslash from final path so the has one, drop trailing backslash from final path so the
below string comparison has a chance to succeed. */ below string comparison has a chance to succeed.
On the contrary, if incoming path has trailing backslash,
but final path does not have one, add trailing backslash
to the final path. */
if (upath.Buffer[(upath.Length - 1) / sizeof (WCHAR)] != L'\\' if (upath.Buffer[(upath.Length - 1) / sizeof (WCHAR)] != L'\\'
&& fpbuf[ret - 1] == L'\\') && fpbuf[ret - 1] == L'\\')
fpbuf[--ret] = L'\0'; fpbuf[--ret] = L'\0';
if (upath.Buffer[(upath.Length - 1) / sizeof (WCHAR)] == L'\\'
&& fpbuf[ret - 1] != L'\\' && ret < NT_MAX_PATH - 1)
{
fpbuf[ret++] = L'\\';
fpbuf[ret] = L'\0';
}
fpbuf[1] = L'?'; /* \\?\ --> \??\ */ fpbuf[1] = L'?'; /* \\?\ --> \??\ */
RtlInitCountedUnicodeString (&fpath, fpbuf, ret * sizeof (WCHAR)); RtlInitCountedUnicodeString (&fpath, fpbuf, ret * sizeof (WCHAR));
if (!RtlEqualUnicodeString (&upath, &fpath, !!ci_flag)) if (!RtlEqualUnicodeString (&upath, &fpath, !!ci_flag))