summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2020-02-05 09:29:33 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-02-10 20:05:04 -0500
commit5670881d7779ecd7eee8c969dab66ee343298532 (patch)
treeb572ca210febec859871f660b4fa0ce2470bfca8
parentf3e737bbcae7290856450ff9c8b0c7e31fca0c10 (diff)
downloadhaskell-5670881d7779ecd7eee8c969dab66ee343298532.tar.gz
Fs: Fix UNC remapping code.
-rw-r--r--utils/fs/fs.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/utils/fs/fs.c b/utils/fs/fs.c
index 4a761e5f9e..f6c8cfda16 100644
--- a/utils/fs/fs.c
+++ b/utils/fs/fs.c
@@ -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)