int remlen = QueryDosDeviceW (drive, remote, MAX_PATH);
if (remlen < 3)
goto file_not_symlink; /* fallback */
- remlen -= 2;
+ remlen -= 2; /* Two L'\0' */
if (remote[remlen - 1] == L'\\')
remlen--;
UNICODE_STRING rpath;
RtlInitCountedUnicodeString (&rpath, remote,
remlen * sizeof (WCHAR));
+ const USHORT uncp_len =
+ ro_u_uncp.Length / sizeof (WCHAR) - 1;
if (RtlEqualUnicodePathPrefix (&rpath, &ro_u_uncp, TRUE))
- remlen -= 6;
+ {
+ remlen -= uncp_len;
+ p = remote + uncp_len;
+ }
else if ((p = wcschr (remote, L';'))
&& p + 3 < remote + remlen
&& wcsncmp (p + 1, drive, 2) == 0
&& (p = wcschr (p + 3, L'\\')))
- remlen -= p - remote - 1;
+ remlen -= p - remote;
else
goto file_not_symlink; /* fallback */
+ if (wcsncasecmp (fpath.Buffer + uncp_len, p, remlen))
+ goto file_not_symlink; /* fallback (not expected) */
/* Hackfest */
fpath.Buffer[4] = drive[0]; /* Drive letter */
fpath.Buffer[5] = L':';
- WCHAR *to = fpath.Buffer + 6;
- WCHAR *from = to + remlen;
+ WCHAR *to = fpath.Buffer + 6; /* Next to L':' */
+ WCHAR *from = fpath.Buffer + uncp_len + remlen;
memmove (to, from,
(wcslen (from) + 1) * sizeof (WCHAR));
fpath.Length -= (from - to) * sizeof (WCHAR);