From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 33D553858D33; Mon, 23 Jan 2023 13:17:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 33D553858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674479822; bh=GyriJw9hEfeViK9JoDBNVD21KRSFapyj9vRMxgayIHc=; h=From:To:Subject:Date:From; b=lTwXAApTwJfUo28OjkG5XYvkAYf0TzM9j9AwMCKlYtbpZitw8HlWfN4KUO5p6xBJi vF8kKeU2Y2h2s1SwK5QNoLh3dJf66mDwuDBXOJaPlnNOXmFQMYRTJAlzbc5vvmtiZf YAr1uxeM1DhThNZa4qUJJg9mKCgddjpIqRG1+cUE= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: mount: differ allowed server name chars from allowed share name chars X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 6338d2f24a609f10363477da29cf883e4a063f83 X-Git-Newrev: cad3913ed8b1ce5db9396edc2f9e461cdb10998b Message-Id: <20230123131702.33D553858D33@sourceware.org> Date: Mon, 23 Jan 2023 13:17:02 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dcad3913ed8b= 1ce5db9396edc2f9e461cdb10998b commit cad3913ed8b1ce5db9396edc2f9e461cdb10998b Author: Corinna Vinschen AuthorDate: Mon Jan 23 14:01:43 2023 +0100 Commit: Corinna Vinschen CommitDate: Mon Jan 23 14:02:20 2023 +0100 Cygwin: mount: differ allowed server name chars from allowed share name= chars =20 The list of invalid chars for server names differs from the list of invalid chars for share names. Apart from that, we don't allow control chars in both kinds of names. =20 Fixes: 6338d2f24a60 ("Cygwin: mount: allow any valid character in UNC p= aths") Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/mount.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc index d8e6e043b8d4..b44d60e1e3eb 100644 --- a/winsup/cygwin/mount.cc +++ b/winsup/cygwin/mount.cc @@ -51,10 +51,23 @@ int NO_COPY mount_info::root_idx =3D -1; This function is only used to test for valid input strings. The later normalization drops the native prefixes. */ =20 +/* list of invalid chars in server names. Note that underscore is ok, + but it cripples interoperability. */ +const char _invalid_server_char[] =3D ",~:!@#$%^&'.(){} "; +#define valid_server_char(_c) ({ \ + const char __c =3D (_c); \ + !iscntrl(__c) \ + && strchr (_invalid_server_char, (_c)) =3D=3D NULL; \ + }) + /* list of invalid chars in UNC filenames. These are a few more than for "normal" filenames. */ -const char _invalid_char[] =3D "\"/\\[]:|<>+=3D;,?*"; -#define valid_share_char(_c) (strchr (_invalid_char, (_c)) =3D=3D NULL) +const char _invalid_share_char[] =3D "\"/\\[]:|<>+=3D;,?*"; +#define valid_share_char(_c) ({ \ + const char __c =3D (_c); \ + !iscntrl(__c) \ + && strchr (_invalid_share_char, __c) =3D=3D NULL; \ + }) =20 static inline bool is_native_path (const char *path) @@ -72,7 +85,7 @@ is_unc_share (const char *path) const char *p; return (isdirsep (path[0]) && isdirsep (path[1]) - && valid_share_char (path[2]) + && valid_server_char (path[2]) && ((p =3D strpbrk (path + 3, "\\/")) !=3D NULL) && valid_share_char (p[1])); }