public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Takashi Yano <tyan0@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_3-branch] Cygwin: path: Add fallback for DFS mounted drive. Date: Mon, 14 Mar 2022 12:55:11 +0000 (GMT) [thread overview] Message-ID: <20220314125511.74918386EC38@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=c098e06d96991694a949a9c913141ae8f9b8e2ba commit c098e06d96991694a949a9c913141ae8f9b8e2ba Author: Takashi Yano <takashi.yano@nifty.ne.jp> Date: Fri Mar 11 17:26:30 2022 +0900 Cygwin: path: Add fallback for DFS mounted drive. - If UNC path for DFS is mounted to a drive with drive letter, the error "Too many levels of symbolic links" occurs when accessing to that drive. This is because GetDosDeviceW() returns unexpected string such as "\Device\Mup\DfsClient\;Z:000000000003fb89\dfsserver \dfs\linkname" for the mounted UNC path "\??\UNC\fileserver\share". This patch adds a workaround for this issue. Addresses: https://cygwin.com/pipermail/cygwin/2022-March/250979.html Diff: --- winsup/cygwin/path.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 4ad4e0821..eceafbbcf 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -3527,7 +3527,7 @@ restart: int remlen = QueryDosDeviceW (drive, remote, MAX_PATH); if (remlen < 3) goto file_not_symlink; /* fallback */ - remlen -= 2; + remlen -= 2; /* Two L'\0' */ if (remote[remlen - 1] == L'\\') remlen--; @@ -3535,20 +3535,27 @@ restart: UNICODE_STRING rpath; RtlInitCountedUnicodeString (&rpath, remote, remlen * sizeof (WCHAR)); + const USHORT uncp_len = + ro_u_uncp.Length / sizeof (WCHAR) - 1; if (RtlEqualUnicodePathPrefix (&rpath, &ro_u_uncp, TRUE)) - remlen -= 6; + { + remlen -= uncp_len; + p = remote + uncp_len; + } else if ((p = wcschr (remote, L';')) && p + 3 < remote + remlen && wcsncmp (p + 1, drive, 2) == 0 && (p = wcschr (p + 3, L'\\'))) - remlen -= p - remote - 1; + remlen -= p - remote; else goto file_not_symlink; /* fallback */ + if (wcsncasecmp (fpath.Buffer + uncp_len, p, remlen)) + goto file_not_symlink; /* fallback (not expected) */ /* Hackfest */ fpath.Buffer[4] = drive[0]; /* Drive letter */ fpath.Buffer[5] = L':'; - WCHAR *to = fpath.Buffer + 6; - WCHAR *from = to + remlen; + WCHAR *to = fpath.Buffer + 6; /* Next to L':' */ + WCHAR *from = fpath.Buffer + uncp_len + remlen; memmove (to, from, (wcslen (from) + 1) * sizeof (WCHAR)); fpath.Length -= (from - to) * sizeof (WCHAR);
reply other threads:[~2022-03-14 12:55 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220314125511.74918386EC38@sourceware.org \ --to=tyan0@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).