From 7760413f6be6cd609325cd8b637ebcb5d00f28d7 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Sat, 4 Oct 2003 03:06:58 +0000 Subject: [PATCH] Fixed a couple of bugs in RtlGetFullPathName_U. --- dlls/ntdll/path.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dlls/ntdll/path.c b/dlls/ntdll/path.c index c17f3f91166..ac123aad90d 100644 --- a/dlls/ntdll/path.c +++ b/dlls/ntdll/path.c @@ -397,7 +397,11 @@ static ULONG get_full_path_helper(LPCWSTR name, LPWSTR buffer, ULONG size) case RELATIVE_PATH: /* foo */ reqsize += cd->Length; - if (reqsize <= size) strcpyW(buffer, cd->Buffer); + if (reqsize <= size) + { + memcpy(buffer, cd->Buffer, cd->Length); + buffer[cd->Length / sizeof(WCHAR)] = 0; + } if (cd->Buffer[1] != ':') { ptr = strchrW(cd->Buffer + 2, '\\'); @@ -501,7 +505,7 @@ static ULONG get_full_path_helper(LPCWSTR name, LPWSTR buffer, ULONG size) break; case '\\': reqsize -= 2 * sizeof(WCHAR); - memmove(ptr + 2, ptr, buffer + reqsize - ptr + sizeof(WCHAR)); + memmove(ptr, ptr + 2, buffer + reqsize - ptr + sizeof(WCHAR)); break; } } @@ -518,7 +522,7 @@ done: * * Returns the number of bytes written to buffer (not including the * terminating NULL) if the function succeeds, or the required number of bytes - * (including the terminating NULL) if the buffer is to small. + * (including the terminating NULL) if the buffer is too small. * * file_part will point to the filename part inside buffer (except if we use * DOS device name, in which case file_in_buf is NULL)