[PATCH] Cygwin: normalize_win32_path: allow drive without trailing backslash

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Cygwin: normalize_win32_path: allow drive without trailing backslash

Ken Brown-6
Commit 283cb372, "Cygwin: normalize_win32_path: improve error
checking", required a prefix '\\?\' or '\??\' in the source path to be
followed by 'UNC\' or 'X:\', where X is a drive letter.  That was too
restrictive, since it disallowed the paths '\\?\X: and '\??\X:'.  This
caused problems when a user tried to use the root of a drive as the
Cygwin installation root, as reported here:

  https://cygwin.com/ml/cygwin/2020-01/msg00111.html

Modify the requirement so that '\??\X:' and '\\?\X:' are now allowed
as source paths, without a trailing backslash.
---
 winsup/cygwin/path.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index c8e73c64c..a00270210 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -1411,7 +1411,7 @@ normalize_win32_path (const char *src, char *dst, char *&tail)
       && src[2] == '?' && isdirsep (src[3]))
     {
       src += 4;
-      if (isdrive (src) && isdirsep (src[2]))
+      if (isdrive (src) && (isdirsep (src[2]) || !src[2]))
  beg_src_slash = false;
       else if (!strncmp (src, "UNC", 3) && isdirsep (src[3]))
  /* native UNC path */
--
2.21.0

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Cygwin: normalize_win32_path: allow drive without trailing backslash

Corinna Vinschen-2
On Jan 15 17:46, Ken Brown wrote:

> Commit 283cb372, "Cygwin: normalize_win32_path: improve error
> checking", required a prefix '\\?\' or '\??\' in the source path to be
> followed by 'UNC\' or 'X:\', where X is a drive letter.  That was too
> restrictive, since it disallowed the paths '\\?\X: and '\??\X:'.  This
> caused problems when a user tried to use the root of a drive as the
> Cygwin installation root, as reported here:
>
>   https://cygwin.com/ml/cygwin/2020-01/msg00111.html
>
> Modify the requirement so that '\??\X:' and '\\?\X:' are now allowed
> as source paths, without a trailing backslash.
> ---
>  winsup/cygwin/path.cc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
> index c8e73c64c..a00270210 100644
> --- a/winsup/cygwin/path.cc
> +++ b/winsup/cygwin/path.cc
> @@ -1411,7 +1411,7 @@ normalize_win32_path (const char *src, char *dst, char *&tail)
>        && src[2] == '?' && isdirsep (src[3]))
>      {
>        src += 4;
> -      if (isdrive (src) && isdirsep (src[2]))
> +      if (isdrive (src) && (isdirsep (src[2]) || !src[2]))
>   beg_src_slash = false;
>        else if (!strncmp (src, "UNC", 3) && isdirsep (src[3]))
>   /* native UNC path */
> --
> 2.21.0
Looks good, please push.


Thanks,
Corinna

--
Corinna Vinschen
Cygwin Maintainer

signature.asc (849 bytes) Download Attachment