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.y...@nifty.ne.jp>