From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH] Cygwin: path: Fix path conversion of virtual drive.
Date: Thu, 9 Dec 2021 20:14:57 +0900 [thread overview]
Message-ID: <20211209201457.97d11b5796075ec8eea87bf9@nifty.ne.jp> (raw)
In-Reply-To: <YbHVrmn+hm7sH23S@calimero.vinschen.de>
On Thu, 9 Dec 2021 11:08:46 +0100
Corinna Vinschen wrote:
> On Dec 9 17:17, Takashi Yano wrote:
> > + if (!QueryDosDeviceW (drive, remote, MAX_PATH))
> > + goto file_not_symlink; /* fallback */
> > +
> > + int remlen = wcslen (remote);
>
> QueryDosDeviceW returns the string followed by two \0 chars, and that's
> reflected by its return value. You could skip the wcslen call:
>
> int remlen;
> remlen = QueryDosDeviceW (drive, remote, MAX_PATH);
> if (!remlen)
> goto file_not_symlink;
> remlen -= 2;
>
>
> > + if (remote[remlen - 1] == L'\\')
> > + remlen--;
> > + WCHAR *p;
> > + if (wcsstr (remote, L"\\??\\UNC\\") == remote)
>
> That should be wcsncmp. The subst'ed UNC path always begins with that
> string. Alternatively:
>
> UNICODE_STRING rpath;
> RtlInitCountedUnicodeString (&rpath, remote,
> remlen * sizeof (WCHAR));
> if (RtlEqualUnicodePathPrefix (&rpath, &ro_u_uncp, TRUE))
>
>
> > + remlen -= 6;
> > + else if ((p = wcschr (remote, L';') + 1)
>
> This expression is always true, even if wcschr returns a NULL pointer.
>
> > + && wcsstr (p, drive) == p
>
> && wcsncmp (p, drive, 2) == 2?
>
> Alternatively just skip the additional drive letter check and move
> the pointer immediately forward to the next backslash:
Thanks for checking and advice. I'll submit v2 patch shortly.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
prev parent reply other threads:[~2021-12-09 11:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-09 8:17 Takashi Yano
2021-12-09 10:08 ` Corinna Vinschen
2021-12-09 11:14 ` Takashi Yano [this message]
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=20211209201457.97d11b5796075ec8eea87bf9@nifty.ne.jp \
--to=takashi.yano@nifty.ne.jp \
--cc=cygwin-patches@cygwin.com \
/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: link
Be 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).