From c7548b6c43a711cc7d11417e795bec0716e88631 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sun, 6 Apr 2014 14:24:00 +0000 Subject: [PATCH] [KERNEL32] - Fix buffer overrun - Fix incorrect return check CID #514675 CID #716130 CID #731615 svn path=/trunk/; revision=62657 --- reactos/dll/win32/kernel32/client/compname.c | 8 +++++--- reactos/dll/win32/kernel32/client/file/copy.c | 2 +- reactos/dll/win32/kernel32/client/vdm.c | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/reactos/dll/win32/kernel32/client/compname.c b/reactos/dll/win32/kernel32/client/compname.c index 8b5784f7b69..aadd7455a7b 100644 --- a/reactos/dll/win32/kernel32/client/compname.c +++ b/reactos/dll/win32/kernel32/client/compname.c @@ -301,10 +301,12 @@ WINAPI GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize) { BOOL ret; + ret = GetComputerNameExA(ComputerNameNetBIOS, lpBuffer, lpnSize); - if(!ret && GetLastError() == ERROR_MORE_DATA) - SetLastError(ERROR_BUFFER_OVERFLOW); - return ret; + if (!ret && GetLastError() == ERROR_MORE_DATA) + SetLastError(ERROR_BUFFER_OVERFLOW); + + return ret; } diff --git a/reactos/dll/win32/kernel32/client/file/copy.c b/reactos/dll/win32/kernel32/client/file/copy.c index a5f3d30ee36..9601e108267 100644 --- a/reactos/dll/win32/kernel32/client/file/copy.c +++ b/reactos/dll/win32/kernel32/client/file/copy.c @@ -325,7 +325,7 @@ CopyFileExA(IN LPCSTR lpExistingFileName, PUNICODE_STRING lpExistingFileNameW; lpExistingFileNameW = Basep8BitStringToStaticUnicodeString(lpExistingFileName); - if (!lpExistingFileName) + if (!lpExistingFileNameW) { return FALSE; } diff --git a/reactos/dll/win32/kernel32/client/vdm.c b/reactos/dll/win32/kernel32/client/vdm.c index 81a42d37f4e..3ff2c466168 100644 --- a/reactos/dll/win32/kernel32/client/vdm.c +++ b/reactos/dll/win32/kernel32/client/vdm.c @@ -232,7 +232,7 @@ BaseGetVdmConfigInfo(IN LPCWSTR CommandLineReserved, * %s%c : Nothing if DOS VDM, -w if WoW VDM, -ws if separate WoW VDM. */ _snwprintf(CommandLine, - sizeof(CommandLine), + sizeof(CommandLine) / sizeof(CommandLine[0]), L"\"%s\\ntvdm.exe\" -i%lx %s%c", Buffer, DosSeqId, @@ -246,7 +246,7 @@ BaseGetVdmConfigInfo(IN LPCWSTR CommandLineReserved, * %s%c : Nothing if DOS VDM, -w if WoW VDM, -ws if separate WoW VDM. */ _snwprintf(CommandLine, - sizeof(CommandLine), + sizeof(CommandLine) / sizeof(CommandLine[0]), L"\"%s\\ntvdm.exe\" %s%c", Buffer, (BinaryType == BINARY_TYPE_DOS) ? L" " : L"-w",