From 8d4679b2b762ba7bd48f54272f861675c5d57a60 Mon Sep 17 00:00:00 2001 From: Ben Payne Date: Thu, 11 Dec 2014 20:07:11 -0500 Subject: [PATCH] Fix potential buffer overflows --- Engine/source/main/main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Engine/source/main/main.cpp b/Engine/source/main/main.cpp index f4c4d95e6..56bed4ceb 100644 --- a/Engine/source/main/main.cpp +++ b/Engine/source/main/main.cpp @@ -75,10 +75,11 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdL return -1; } + enum { errorSize = 4096 }; if (!hGame) { - wchar_t error[4096]; - _swprintf_l(error, sizeof(error), L"Unable to load game library: %s. Please make sure it exists and the latest DirectX is installed.", _get_current_locale(), dllName.c_str()); + wchar_t error[errorSize]; + _swprintf_l(error, errorSize, L"Unable to load game library: %s. Please make sure it exists and the latest DirectX is installed.", _get_current_locale(), dllName.c_str()); MessageBoxW(NULL, error, L"Error", MB_OK|MB_ICONWARNING); return -1; } @@ -86,8 +87,8 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdL torque_winmain = (int (*)(HINSTANCE hInstance, HINSTANCE h, LPSTR lpszCmdLine, int nShow))GetProcAddress(hGame, "torque_winmain"); if (!torque_winmain) { - wchar_t error[4096]; - _swprintf_l(error, sizeof(error), L"Missing torque_winmain export in game library: %s. Please make sure that it exists and the latest DirectX is installed.", _get_current_locale(), dllName.c_str()); + wchar_t error[errorSize]; + _swprintf_l(error, errorSize, L"Missing torque_winmain export in game library: %s. Please make sure that it exists and the latest DirectX is installed.", _get_current_locale(), dllName.c_str()); MessageBoxW(NULL, error, L"Error", MB_OK|MB_ICONWARNING); return -1; }