Преглед на файлове

Fix potential buffer overflows

Ben Payne преди 10 години
родител
ревизия
8d4679b2b7
променени са 1 файла, в които са добавени 5 реда и са изтрити 4 реда
  1. 5 4
      Engine/source/main/main.cpp

+ 5 - 4
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;
    }