diff options
-rw-r--r-- | erts/emulator/nifs/win32/win_prim_file.c | 9 | ||||
-rw-r--r-- | lib/kernel/test/file_SUITE.erl | 3 |
2 files changed, 9 insertions, 3 deletions
diff --git a/erts/emulator/nifs/win32/win_prim_file.c b/erts/emulator/nifs/win32/win_prim_file.c index d0aa70542f..e7d3924240 100644 --- a/erts/emulator/nifs/win32/win_prim_file.c +++ b/erts/emulator/nifs/win32/win_prim_file.c @@ -142,12 +142,15 @@ static posix_errno_t get_full_path(ErlNifEnv *env, WCHAR *input, efile_path_t *r maybe_unc_path = !sys_memcmp(result->data, L"\\\\", sizeof(WCHAR) * 2); if(maybe_unc_path && !is_long_path) { - /* \\localhost\c$\gurka -> \\?\UNC\localhost\c$\gurka */ + /* \\localhost\c$\gurka -> \\?\UNC\localhost\c$\gurka + * + * Note that the length is reduced by 2 as the "\\" is replaced by + * the UNC prefix */ sys_memmove(result->data + LP_UNC_PREFIX_SIZE, &((WCHAR*)result->data)[2], - (actual_length - 1) * sizeof(WCHAR)); + (actual_length + 1 - 2) * sizeof(WCHAR)); sys_memcpy(result->data, LP_UNC_PREFIX, LP_UNC_PREFIX_SIZE); - actual_length += LP_UNC_PREFIX_LENGTH; + actual_length += LP_UNC_PREFIX_LENGTH - 2; } else if(!is_long_path) { /* C:\gurka -> \\?\C:\gurka */ sys_memmove(result->data + LP_PREFIX_SIZE, result->data, diff --git a/lib/kernel/test/file_SUITE.erl b/lib/kernel/test/file_SUITE.erl index a51025cba6..711ffccb67 100644 --- a/lib/kernel/test/file_SUITE.erl +++ b/lib/kernel/test/file_SUITE.erl @@ -2191,6 +2191,9 @@ unc_paths(Config) when is_list(Config) -> {ok, _} = file:read_file_info("C:\\Windows\\explorer.exe"), {ok, _} = file:read_file_info("\\\\localhost\\c$\\Windows\\explorer.exe"), + {ok, Files} = file:list_dir("C:\\Windows\\"), + {ok, Files} = file:list_dir("\\\\localhost\\c$\\Windows\\"), + {ok, Cwd} = file:get_cwd(), try |