From dce765d5f88c6bc9a8eca7e686774b662cf8aa50 Mon Sep 17 00:00:00 2001 From: Skyaero <21192585+Skyaero42@users.noreply.github.com> Date: Wed, 5 Nov 2025 21:22:48 +0100 Subject: [PATCH 1/2] safeguard: Add static_asserts to strcpy calls to prevent buffer overflow risks --- .../Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp | 9 +++++++++ .../W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp | 2 ++ .../Source/W3DDevice/GameClient/W3DFileSystem.cpp | 6 ++++++ Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp | 2 ++ .../Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp | 9 +++++++++ .../W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp | 2 ++ .../Source/W3DDevice/GameClient/W3DFileSystem.cpp | 6 ++++++ GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp | 2 ++ 8 files changed, 38 insertions(+) diff --git a/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp b/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp index 71227d8646..9aeabad3f6 100644 --- a/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp +++ b/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp @@ -504,6 +504,7 @@ void BuddyThreadClass::errorCallback( GPConnection *con, GPErrorArg *arg ) static void getNickForMessage( GPConnection *con, GPGetInfoResponseArg *arg, void *param ) { BuddyResponse *resp = (BuddyResponse *)param; + static_assert(ARRAY_SIZE(resp->arg.message.nick) >= ARRAY_SIZE(arg->nick), "Incorrect array size"); strcpy(resp->arg.message.nick, arg->nick); } @@ -618,6 +619,9 @@ static void getInfoResponseForRequest( GPConnection *con, GPGetInfoResponseArg * { BuddyResponse *resp = (BuddyResponse *)param; resp->profile = arg->profile; + static_assert(ARRAY_SIZE(resp->arg.request.nick) >= ARRAY_SIZE(arg->nick), "Incorrect array size"); + static_assert(ARRAY_SIZE(resp->arg.request.email) >= ARRAY_SIZE(arg->email), "Incorrect array size"); + static_assert(ARRAY_SIZE(resp->arg.request.countrycode) >= ARRAY_SIZE(arg->countrycode), "Incorrect array size"); strcpy(resp->arg.request.nick, arg->nick); strcpy(resp->arg.request.email, arg->email); strcpy(resp->arg.request.countrycode, arg->countrycode); @@ -644,6 +648,9 @@ static void getInfoResponseForStatus(GPConnection * connection, GPGetInfoRespons { BuddyResponse *resp = (BuddyResponse *)param; resp->profile = arg->profile; + static_assert(ARRAY_SIZE(resp->arg.status.nick) >= ARRAY_SIZE(arg->nick), "Incorrect array size"); + static_assert(ARRAY_SIZE(resp->arg.status.email) >= ARRAY_SIZE(arg->email), "Incorrect array size"); + static_assert(ARRAY_SIZE(resp->arg.status.countrycode) >= ARRAY_SIZE(arg->countrycode), "Incorrect array size"); strcpy(resp->arg.status.nick, arg->nick); strcpy(resp->arg.status.email, arg->email); strcpy(resp->arg.status.countrycode, arg->countrycode); @@ -660,6 +667,8 @@ void BuddyThreadClass::statusCallback( GPConnection *con, GPRecvBuddyStatusArg * // get user's status GPBuddyStatus status; gpGetBuddyStatus( con, arg->index, &status ); + static_assert(ARRAY_SIZE(response.arg.status.location) >= ARRAY_SIZE(status.locationString), "Incorrect array size"); + static_assert(ARRAY_SIZE(response.arg.status.statusString) >= ARRAY_SIZE(status.statusString), "Incorrect array size"); strcpy(response.arg.status.location, status.locationString); strcpy(response.arg.status.statusString, status.statusString); response.arg.status.status = status.status; diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp index 3f36d54e3d..1fdb12e426 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp @@ -1718,6 +1718,7 @@ W3DProjectedShadow* W3DProjectedShadowManager::addShadow(RenderObjClass *robj, S //onto world geometry. if (strlen(shadowInfo->m_ShadowName) <= 1) //no texture name given, use same as object { + static_assert(ARRAY_SIZE(defaultDecalName) < ARRAY_SIZE(texture_name), "Incorrect array size"); strcpy(texture_name, defaultDecalName); } else @@ -1894,6 +1895,7 @@ W3DProjectedShadow* W3DProjectedShadowManager::createDecalShadow(Shadow::ShadowT //onto world geometry. if (strlen(shadowInfo->m_ShadowName) <= 1) //no texture name given, use same as object { + static_assert(ARRAY_SIZE(defaultDecalName) < ARRAY_SIZE(texture_name), "Incorrect array size"); strcpy(texture_name,defaultDecalName); } else diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp index 1870b062d9..bf9b598693 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp @@ -157,6 +157,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { + static_assert(ARRAY_SIZE(W3D_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); strcpy( m_filePath, W3D_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -164,6 +165,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { + static_assert(ARRAY_SIZE(TGA_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); strcpy( m_filePath, TGA_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -182,6 +184,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { + static_assert(ARRAY_SIZE(LEGACY_W3D_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); strcpy( m_filePath, LEGACY_W3D_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -189,6 +192,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { + static_assert(ARRAY_SIZE(LEGACY_TGA_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); strcpy( m_filePath, LEGACY_TGA_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -208,6 +212,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { + static_assert(ARRAY_SIZE(TEST_W3D_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); strcpy( m_filePath, TEST_W3D_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -215,6 +220,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { + static_assert(ARRAY_SIZE(TEST_TGA_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); strcpy( m_filePath, TEST_TGA_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); diff --git a/Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp b/Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp index 918e42976f..c342ce74bc 100644 --- a/Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp @@ -246,6 +246,7 @@ BOOL RoadOptions::OnInitDialog() char findBuf[_MAX_PATH]; char fileBuf[_MAX_PATH]; + static_assert(ARRAY_SIZE(ROAD_DIRECTORY) <= ARRAY_SIZE(dirBuf), "Buffer size too small"); strcpy(dirBuf, ROAD_DIRECTORY); int len = strlen(dirBuf); @@ -273,6 +274,7 @@ BOOL RoadOptions::OnInitDialog() ++it; continue; } + static_assert(ARRAY_SIZE(TEST_STRING) <= ARRAY_SIZE(fileBuf), "Buffer size too small"); strcpy(fileBuf, TEST_STRING); strlcat(fileBuf, "\\", ARRAY_SIZE(fileBuf)); strlcat(fileBuf, filename.str(), ARRAY_SIZE(fileBuf)); diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp index 832eb912d5..29f04c4fb7 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp @@ -504,6 +504,7 @@ void BuddyThreadClass::errorCallback( GPConnection *con, GPErrorArg *arg ) static void getNickForMessage( GPConnection *con, GPGetInfoResponseArg *arg, void *param ) { BuddyResponse *resp = (BuddyResponse *)param; + static_assert(ARRAY_SIZE(resp->arg.message.nick) >= ARRAY_SIZE(arg->nick), "Incorrect array size"); strcpy(resp->arg.message.nick, arg->nick); } @@ -618,6 +619,9 @@ static void getInfoResponseForRequest( GPConnection *con, GPGetInfoResponseArg * { BuddyResponse *resp = (BuddyResponse *)param; resp->profile = arg->profile; + static_assert(ARRAY_SIZE(resp->arg.request.nick) >= ARRAY_SIZE(arg->nick), "Incorrect array size"); + static_assert(ARRAY_SIZE(resp->arg.request.email) >= ARRAY_SIZE(arg->email), "Incorrect array size"); + static_assert(ARRAY_SIZE(resp->arg.request.countrycode) >= ARRAY_SIZE(arg->countrycode), "Incorrect array size"); strcpy(resp->arg.request.nick, arg->nick); strcpy(resp->arg.request.email, arg->email); strcpy(resp->arg.request.countrycode, arg->countrycode); @@ -644,6 +648,9 @@ static void getInfoResponseForStatus(GPConnection * connection, GPGetInfoRespons { BuddyResponse *resp = (BuddyResponse *)param; resp->profile = arg->profile; + static_assert(ARRAY_SIZE(resp->arg.status.nick) >= ARRAY_SIZE(arg->nick), "Incorrect array size"); + static_assert(ARRAY_SIZE(resp->arg.status.email) >= ARRAY_SIZE(arg->email), "Incorrect array size"); + static_assert(ARRAY_SIZE(resp->arg.status.countrycode) >= ARRAY_SIZE(arg->countrycode), "Incorrect array size"); strcpy(resp->arg.status.nick, arg->nick); strcpy(resp->arg.status.email, arg->email); strcpy(resp->arg.status.countrycode, arg->countrycode); @@ -660,6 +667,8 @@ void BuddyThreadClass::statusCallback( GPConnection *con, GPRecvBuddyStatusArg * // get user's status GPBuddyStatus status; gpGetBuddyStatus( con, arg->index, &status ); + static_assert(ARRAY_SIZE(response.arg.status.location) >= ARRAY_SIZE(status.locationString), "Incorrect array size"); + static_assert(ARRAY_SIZE(response.arg.status.statusString) >= ARRAY_SIZE(status.statusString), "Incorrect array size"); strcpy(response.arg.status.location, status.locationString); strcpy(response.arg.status.statusString, status.statusString); response.arg.status.status = status.status; diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp index 33c0782c72..acad2f99d7 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp @@ -1718,6 +1718,7 @@ W3DProjectedShadow* W3DProjectedShadowManager::addShadow(RenderObjClass *robj, S //onto world geometry. if (strlen(shadowInfo->m_ShadowName) <= 1) //no texture name given, use same as object { + static_assert(ARRAY_SIZE(defaultDecalName) < ARRAY_SIZE(texture_name), "Incorrect array size"); strcpy(texture_name, defaultDecalName); } else @@ -1894,6 +1895,7 @@ W3DProjectedShadow* W3DProjectedShadowManager::createDecalShadow(Shadow::ShadowT //onto world geometry. if (strlen(shadowInfo->m_ShadowName) <= 1) //no texture name given, use same as object { + static_assert(ARRAY_SIZE(defaultDecalName) < ARRAY_SIZE(texture_name), "Incorrect array size"); strcpy(texture_name, defaultDecalName); } else diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp index eae8ffc250..46ee1d89dc 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp @@ -197,6 +197,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { + static_assert(ARRAY_SIZE(W3D_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); strcpy( m_filePath, W3D_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -204,6 +205,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { + static_assert(ARRAY_SIZE(TGA_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); strcpy( m_filePath, TGA_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -225,6 +227,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { + static_assert(ARRAY_SIZE(LEGACY_W3D_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); strcpy( m_filePath, LEGACY_W3D_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -232,6 +235,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { + static_assert(ARRAY_SIZE(LEGACY_TGA_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); strcpy( m_filePath, LEGACY_TGA_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -253,6 +257,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { + static_assert(ARRAY_SIZE(TEST_W3D_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); strcpy( m_filePath, TEST_W3D_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -260,6 +265,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { + static_assert(ARRAY_SIZE(TEST_TGA_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); strcpy( m_filePath, TEST_TGA_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp index 861182155c..b819b84e93 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp @@ -246,6 +246,7 @@ BOOL RoadOptions::OnInitDialog() char findBuf[_MAX_PATH]; char fileBuf[_MAX_PATH]; + static_assert(ARRAY_SIZE(ROAD_DIRECTORY) <= ARRAY_SIZE(dirBuf), "Buffer size too small"); strcpy(dirBuf, ROAD_DIRECTORY); int len = strlen(dirBuf); @@ -273,6 +274,7 @@ BOOL RoadOptions::OnInitDialog() ++it; continue; } + static_assert(ARRAY_SIZE(TEST_STRING) <= ARRAY_SIZE(fileBuf), "Buffer size too small"); strcpy(fileBuf, TEST_STRING); strlcat(fileBuf, "\\", ARRAY_SIZE(fileBuf)); strlcat(fileBuf, filename.str(), ARRAY_SIZE(fileBuf)); From 8d9dc27dca44a518a414c0734cd478830ff92c4c Mon Sep 17 00:00:00 2001 From: Skyaero <21192585+Skyaero42@users.noreply.github.com> Date: Thu, 6 Nov 2025 09:17:30 +0100 Subject: [PATCH 2/2] update after review --- .../GameClient/Shadow/W3DProjectedShadow.cpp | 4 ++-- .../Source/W3DDevice/GameClient/W3DFileSystem.cpp | 12 ++++++------ Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp | 4 ++-- .../GameClient/Shadow/W3DProjectedShadow.cpp | 4 ++-- .../Source/W3DDevice/GameClient/W3DFileSystem.cpp | 12 ++++++------ .../Code/Tools/WorldBuilder/src/RoadOptions.cpp | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp index 1fdb12e426..e14d435c5c 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp @@ -1718,7 +1718,7 @@ W3DProjectedShadow* W3DProjectedShadowManager::addShadow(RenderObjClass *robj, S //onto world geometry. if (strlen(shadowInfo->m_ShadowName) <= 1) //no texture name given, use same as object { - static_assert(ARRAY_SIZE(defaultDecalName) < ARRAY_SIZE(texture_name), "Incorrect array size"); + static_assert(ARRAY_SIZE(texture_name) >= ARRAY_SIZE(defaultDecalName), "Incorrect array size"); strcpy(texture_name, defaultDecalName); } else @@ -1895,7 +1895,7 @@ W3DProjectedShadow* W3DProjectedShadowManager::createDecalShadow(Shadow::ShadowT //onto world geometry. if (strlen(shadowInfo->m_ShadowName) <= 1) //no texture name given, use same as object { - static_assert(ARRAY_SIZE(defaultDecalName) < ARRAY_SIZE(texture_name), "Incorrect array size"); + static_assert(ARRAY_SIZE(texture_name) >= ARRAY_SIZE(defaultDecalName), "Incorrect array size"); strcpy(texture_name,defaultDecalName); } else diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp index bf9b598693..75563a0951 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp @@ -157,7 +157,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { - static_assert(ARRAY_SIZE(W3D_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); + static_assert(ARRAY_SIZE(m_filePath) >= ARRAY_SIZE(W3D_DIR_PATH), "Incorrect array size"); strcpy( m_filePath, W3D_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -165,7 +165,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { - static_assert(ARRAY_SIZE(TGA_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); + static_assert(ARRAY_SIZE(m_filePath) >= ARRAY_SIZE(TGA_DIR_PATH), "Incorrect array size"); strcpy( m_filePath, TGA_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -184,7 +184,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { - static_assert(ARRAY_SIZE(LEGACY_W3D_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); + static_assert(ARRAY_SIZE(m_filePath) >= ARRAY_SIZE(LEGACY_W3D_DIR_PATH), "Incorrect array size"); strcpy( m_filePath, LEGACY_W3D_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -192,7 +192,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { - static_assert(ARRAY_SIZE(LEGACY_TGA_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); + static_assert(ARRAY_SIZE(m_filePath) >= ARRAY_SIZE(LEGACY_TGA_DIR_PATH), "Incorrect array size"); strcpy( m_filePath, LEGACY_TGA_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -212,7 +212,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { - static_assert(ARRAY_SIZE(TEST_W3D_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); + static_assert(ARRAY_SIZE(m_filePath) >= ARRAY_SIZE(TEST_W3D_DIR_PATH), "Incorrect array size"); strcpy( m_filePath, TEST_W3D_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -220,7 +220,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { - static_assert(ARRAY_SIZE(TEST_TGA_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); + static_assert(ARRAY_SIZE(m_filePath) >= ARRAY_SIZE(TEST_TGA_DIR_PATH), "Incorrect array size"); strcpy( m_filePath, TEST_TGA_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); diff --git a/Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp b/Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp index c342ce74bc..694b1de6cb 100644 --- a/Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp @@ -246,7 +246,7 @@ BOOL RoadOptions::OnInitDialog() char findBuf[_MAX_PATH]; char fileBuf[_MAX_PATH]; - static_assert(ARRAY_SIZE(ROAD_DIRECTORY) <= ARRAY_SIZE(dirBuf), "Buffer size too small"); + static_assert(ARRAY_SIZE(dirBuf) >= ARRAY_SIZE(ROAD_DIRECTORY), "Incorrect array size"); strcpy(dirBuf, ROAD_DIRECTORY); int len = strlen(dirBuf); @@ -274,7 +274,7 @@ BOOL RoadOptions::OnInitDialog() ++it; continue; } - static_assert(ARRAY_SIZE(TEST_STRING) <= ARRAY_SIZE(fileBuf), "Buffer size too small"); + static_assert(ARRAY_SIZE(fileBuf) >= ARRAY_SIZE(TEST_STRING), "Incorrect array size"); strcpy(fileBuf, TEST_STRING); strlcat(fileBuf, "\\", ARRAY_SIZE(fileBuf)); strlcat(fileBuf, filename.str(), ARRAY_SIZE(fileBuf)); diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp index acad2f99d7..3ca23283ca 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp @@ -1718,7 +1718,7 @@ W3DProjectedShadow* W3DProjectedShadowManager::addShadow(RenderObjClass *robj, S //onto world geometry. if (strlen(shadowInfo->m_ShadowName) <= 1) //no texture name given, use same as object { - static_assert(ARRAY_SIZE(defaultDecalName) < ARRAY_SIZE(texture_name), "Incorrect array size"); + static_assert(ARRAY_SIZE(texture_name) >= ARRAY_SIZE(defaultDecalName), "Incorrect array size"); strcpy(texture_name, defaultDecalName); } else @@ -1895,7 +1895,7 @@ W3DProjectedShadow* W3DProjectedShadowManager::createDecalShadow(Shadow::ShadowT //onto world geometry. if (strlen(shadowInfo->m_ShadowName) <= 1) //no texture name given, use same as object { - static_assert(ARRAY_SIZE(defaultDecalName) < ARRAY_SIZE(texture_name), "Incorrect array size"); + static_assert(ARRAY_SIZE(texture_name) >= ARRAY_SIZE(defaultDecalName), "Incorrect array size"); strcpy(texture_name, defaultDecalName); } else diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp index 46ee1d89dc..3630c227c6 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp @@ -197,7 +197,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { - static_assert(ARRAY_SIZE(W3D_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); + static_assert(ARRAY_SIZE(m_filePath) >= ARRAY_SIZE(W3D_DIR_PATH), "Incorrect array size"); strcpy( m_filePath, W3D_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -205,7 +205,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { - static_assert(ARRAY_SIZE(TGA_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); + static_assert(ARRAY_SIZE(m_filePath) >= ARRAY_SIZE(TGA_DIR_PATH), "Incorrect array size"); strcpy( m_filePath, TGA_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -227,7 +227,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { - static_assert(ARRAY_SIZE(LEGACY_W3D_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); + static_assert(ARRAY_SIZE(m_filePath) >= ARRAY_SIZE(LEGACY_W3D_DIR_PATH), "Incorrect array size"); strcpy( m_filePath, LEGACY_W3D_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -235,7 +235,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { - static_assert(ARRAY_SIZE(LEGACY_TGA_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); + static_assert(ARRAY_SIZE(m_filePath) >= ARRAY_SIZE(LEGACY_TGA_DIR_PATH), "Incorrect array size"); strcpy( m_filePath, LEGACY_TGA_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -257,7 +257,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { - static_assert(ARRAY_SIZE(TEST_W3D_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); + static_assert(ARRAY_SIZE(m_filePath) >= ARRAY_SIZE(TEST_W3D_DIR_PATH), "Incorrect array size"); strcpy( m_filePath, TEST_W3D_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); @@ -265,7 +265,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { - static_assert(ARRAY_SIZE(TEST_TGA_DIR_PATH) < ARRAY_SIZE(m_filePath), "Incorrect array size"); + static_assert(ARRAY_SIZE(m_filePath) >= ARRAY_SIZE(TEST_TGA_DIR_PATH), "Incorrect array size"); strcpy( m_filePath, TEST_TGA_DIR_PATH ); strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp index b819b84e93..e3c98a434c 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp @@ -246,7 +246,7 @@ BOOL RoadOptions::OnInitDialog() char findBuf[_MAX_PATH]; char fileBuf[_MAX_PATH]; - static_assert(ARRAY_SIZE(ROAD_DIRECTORY) <= ARRAY_SIZE(dirBuf), "Buffer size too small"); + static_assert(ARRAY_SIZE(dirBuf) >= ARRAY_SIZE(ROAD_DIRECTORY), "Incorrect array size"); strcpy(dirBuf, ROAD_DIRECTORY); int len = strlen(dirBuf); @@ -274,7 +274,7 @@ BOOL RoadOptions::OnInitDialog() ++it; continue; } - static_assert(ARRAY_SIZE(TEST_STRING) <= ARRAY_SIZE(fileBuf), "Buffer size too small"); + static_assert(ARRAY_SIZE(fileBuf) >= ARRAY_SIZE(TEST_STRING), "Incorrect array size"); strcpy(fileBuf, TEST_STRING); strlcat(fileBuf, "\\", ARRAY_SIZE(fileBuf)); strlcat(fileBuf, filename.str(), ARRAY_SIZE(fileBuf));