Commit 5670881d authored by Tamar Christina's avatar Tamar Christina Committed by Marge Bot

Fs: Fix UNC remapping code.

parent f3e737bb
......@@ -91,12 +91,16 @@ wchar_t* FS(create_device_name) (const wchar_t* filename) {
free (temp);
int startOffset = 0;
/* When remapping a network share, \\foo needs to become
\\?\UNC\foo and not \\?\\UNC\\foo which is an invalid path. */
if (wcsncmp (network_share, result, 2) == 0)
{
if (swprintf (ns, 10, L"%ls%ls", win32_file_namespace, unc_prefix) <= 0)
{
goto cleanup;
}
startOffset = 2;
}
else if (swprintf (ns, 10, L"%ls", win32_file_namespace) <= 0)
{
......@@ -104,8 +108,8 @@ wchar_t* FS(create_device_name) (const wchar_t* filename) {
}
/* Create new string. */
int bLen = wcslen (result) + wcslen (ns) + 1;
temp = _wcsdup (result);
int bLen = wcslen (result) + wcslen (ns) + 1 - startOffset;
temp = _wcsdup (result + startOffset);
free (result);
result = malloc (bLen * sizeof (wchar_t));
if (swprintf (result, bLen, L"%ls%ls", ns, temp) <= 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment