[REACTOS] Fix 64 bit issues

This commit is contained in:
Timo Kreuzer 2018-07-07 16:09:03 +02:00
parent 0f8439aa71
commit cf77354dce
11 changed files with 36 additions and 26 deletions

View file

@ -70,20 +70,20 @@ LogToFile(LPCWSTR lpMsg,
UINT flags)
{
LPWSTR lpFullMsg = NULL;
DWORD msgLen;
SIZE_T msgLen;
msgLen = wcslen(lpMsg) + 1;
if (flags & LOG_ERROR)
{
LPVOID lpSysMsg;
LPWSTR lpSysMsg;
DWORD eMsgLen;
eMsgLen = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
errNum,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&lpSysMsg,
(LPWSTR)&lpSysMsg,
0,
NULL);
@ -122,6 +122,13 @@ LogToFile(LPCWSTR lpMsg,
}
}
/* Make sure the length in bytes doesn't overflow a DWORD */
msgLen = wcslen(lpFullMsg);
if (msgLen > (MAXDWORD / sizeof(WCHAR)))
{
RaiseException(EXCEPTION_INT_OVERFLOW, 0, 0, NULL);
}
if (lpFullMsg)
{
DWORD bytesWritten;
@ -130,7 +137,7 @@ LogToFile(LPCWSTR lpMsg,
bRet = WriteFile(hLogFile,
lpFullMsg,
wcslen(lpFullMsg) * sizeof(WCHAR),
(DWORD)msgLen * sizeof(WCHAR),
&bytesWritten,
&olWrite);
if (!bRet)