public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: mount: allow any valid character in UNC paths
@ 2023-01-22 19:20 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-01-22 19:20 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=6338d2f24a609f10363477da29cf883e4a063f83
commit 6338d2f24a609f10363477da29cf883e4a063f83
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Sun Jan 22 20:11:59 2023 +0100
Commit: Corinna Vinschen <corinna@vinschen.de>
CommitDate: Sun Jan 22 20:15:37 2023 +0100
Cygwin: mount: allow any valid character in UNC paths
The current code only allows server and share names to
start with ASCII chars [a-zA-Z0-9],, which is not correct.
Rather, check for a valid share character.
Fixes: 1fd5e000ace55 ("import winsup-2000-02-17 snapshot")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/mount.cc | 15 ++++++++++++---
winsup/cygwin/release/3.4.6 | 3 +++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc
index 9b40c4075aab..d8e6e043b8d4 100644
--- a/winsup/cygwin/mount.cc
+++ b/winsup/cygwin/mount.cc
@@ -42,11 +42,20 @@ bool NO_COPY mount_info::got_usr_bin;
bool NO_COPY mount_info::got_usr_lib;
int NO_COPY mount_info::root_idx = -1;
-/* is_unc_share: Return non-zero if PATH begins with //server/share
+/* is_native_path: Return non-zero if PATH starts with \??\[a-zA-Z] or
+ with \\?\[a-zA-Z] or with \\.\[a-zA-Z].
+
+ is_unc_share: Return non-zero if PATH begins with //server/share
or with one of the native prefixes //./ or //?/
+
This function is only used to test for valid input strings.
The later normalization drops the native prefixes. */
+/* list of invalid chars in UNC filenames. These are a few more than
+ for "normal" filenames. */
+const char _invalid_char[] = "\"/\\[]:|<>+=;,?*";
+#define valid_share_char(_c) (strchr (_invalid_char, (_c)) == NULL)
+
static inline bool
is_native_path (const char *path)
{
@@ -63,9 +72,9 @@ is_unc_share (const char *path)
const char *p;
return (isdirsep (path[0])
&& isdirsep (path[1])
- && isalnum (path[2])
+ && valid_share_char (path[2])
&& ((p = strpbrk (path + 3, "\\/")) != NULL)
- && isalnum (p[1]));
+ && valid_share_char (p[1]));
}
/* Return true if src_path is a valid, internally supported device name.
diff --git a/winsup/cygwin/release/3.4.6 b/winsup/cygwin/release/3.4.6
index c1476ff4602b..c21c44fbf55a 100644
--- a/winsup/cygwin/release/3.4.6
+++ b/winsup/cygwin/release/3.4.6
@@ -3,3 +3,6 @@ Bug Fixes
Fix a problem that fsync returns EINVAL for block device.
Addresses: https://cygwin.com/pipermail/cygwin/2023-January/252916.html
+
+Don't reject valid server and share names when mounting.
+Addresses: https://cygwin.com/pipermail/cygwin/2023-January/252928.html
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-22 19:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-22 19:20 [newlib-cygwin/main] Cygwin: mount: allow any valid character in UNC paths Corinna Vinschen
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).