diff options
author | Takashi Yano <takashi.yano@nifty.ne.jp> | 2022-02-03 12:00:14 +0900 |
---|---|---|
committer | Takashi Yano <takashi.yano@nifty.ne.jp> | 2022-02-03 12:21:21 +0900 |
commit | e5aca9ced94c1e42390f1d0a2fd7eb2ae09bd5a3 (patch) | |
tree | 16ff4c2be281aa90e2ab87f25cea4d3c15745512 /winsup | |
parent | 4a70041dfd3e42f743ef21d788be65e7fac7e9e7 (diff) | |
download | newlib-e5aca9ced94c1e42390f1d0a2fd7eb2ae09bd5a3.zip newlib-e5aca9ced94c1e42390f1d0a2fd7eb2ae09bd5a3.tar.gz newlib-e5aca9ced94c1e42390f1d0a2fd7eb2ae09bd5a3.tar.bz2 |
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.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/path.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 87ac240..4ad4e08 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -3495,10 +3495,19 @@ restart: /* If incoming path has no trailing backslash, but final path 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'\\' - && fpbuf[ret - 1] == L'\\') + && fpbuf[ret - 1] == L'\\') 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'?'; /* \\?\ --> \??\ */ RtlInitCountedUnicodeString (&fpath, fpbuf, ret * sizeof (WCHAR)); if (!RtlEqualUnicodeString (&upath, &fpath, !!ci_flag)) |