aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/drivers/win32
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-03-18 16:00:44 +0100
committerSverker Eriksson <[email protected]>2014-03-24 21:09:50 +0100
commit3700d457197ae91ba75248d19716005c4013c177 (patch)
tree615451a3f56fc91d09a33f2fe1f2f009dc6fcd38 /erts/emulator/drivers/win32
parent59d685db76ebb20b0bdf765fe387112265cbe923 (diff)
downloadotp-3700d457197ae91ba75248d19716005c4013c177.tar.gz
otp-3700d457197ae91ba75248d19716005c4013c177.tar.bz2
otp-3700d457197ae91ba75248d19716005c4013c177.zip
erts: Fix bug in efile_readlink for long win paths
Diffstat (limited to 'erts/emulator/drivers/win32')
-rw-r--r--erts/emulator/drivers/win32/win_efile.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/erts/emulator/drivers/win32/win_efile.c b/erts/emulator/drivers/win32/win_efile.c
index 4176f137c1..9621fcca45 100644
--- a/erts/emulator/drivers/win32/win_efile.c
+++ b/erts/emulator/drivers/win32/win_efile.c
@@ -1787,7 +1787,7 @@ do_readlink(Efile_call_state* state, char* name, char* buffer, size_t size)
HINSTANCE hModule = NULL;
WCHAR *wname = (WCHAR *) name;
WCHAR *wbuffer = (WCHAR *) buffer;
- DWORD wsize = size / sizeof(WCHAR) - 1;
+ DWORD wsize = size / sizeof(WCHAR);
char* ret = NULL;
if ((hModule = LoadLibrary("kernel32.dll")) != NULL) {
@@ -1815,12 +1815,12 @@ do_readlink(Efile_call_state* state, char* name, char* buffer, size_t size)
wsize = pGetFinalPathNameByHandle(h, &dummy, 0, 0);
if (wsize) {
wbuffer = wpath_tmp_alloc(state, wsize);
- wsize--;
}
}
if (wbuffer
&& (success = pGetFinalPathNameByHandle(h, wbuffer, wsize, 0))
- && success <= wsize) {
+ && success < wsize) {
+ WCHAR* wp;
/* GetFinalPathNameByHandle prepends path with "\\?\": */
len = wcslen(wbuffer);
@@ -1830,9 +1830,9 @@ do_readlink(Efile_call_state* state, char* name, char* buffer, size_t size)
wbuffer[0] = wbuffer[0] + L'a' - L'A';
}
- for ( ; *wbuffer; wbuffer++)
- if (*wbuffer == L'\\')
- *wbuffer = L'/';
+ for (wp=wbuffer ; *wp; wp++)
+ if (*wp == L'\\')
+ *wp = L'/';
}
CloseHandle(h);
}