aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-03-22 09:38:48 +0100
committerJohn Högberg <[email protected]>2019-03-22 09:38:48 +0100
commit4c744d0c81273c4c53a0dd267baf46a71814196e (patch)
treef2bc8d300ac428edb69b7ef3b63ef52cdd392f56 /erts/emulator
parent86184644edc60f03be13b5dcb143a7ac425eccc9 (diff)
parent526bc873d91b134ffab0c484553d42a510bccd96 (diff)
downloadotp-4c744d0c81273c4c53a0dd267baf46a71814196e.tar.gz
otp-4c744d0c81273c4c53a0dd267baf46a71814196e.tar.bz2
otp-4c744d0c81273c4c53a0dd267baf46a71814196e.zip
Merge branch 'john/erts/unc-path-size-fix/OTP-15693'
* john/erts/unc-path-size-fix/OTP-15693: erts: Fix incorrect UNC path length calculation
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/nifs/win32/win_prim_file.c9
1 files changed, 6 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,