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..e14d435c5c 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(texture_name) >= ARRAY_SIZE(defaultDecalName), "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(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 1870b062d9..75563a0951 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(m_filePath) >= ARRAY_SIZE(W3D_DIR_PATH), "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(m_filePath) >= ARRAY_SIZE(TGA_DIR_PATH), "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(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)); @@ -189,6 +192,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { + 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)); @@ -208,6 +212,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { + 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)); @@ -215,6 +220,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { + 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 918e42976f..694b1de6cb 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(dirBuf) >= ARRAY_SIZE(ROAD_DIRECTORY), "Incorrect array size"); strcpy(dirBuf, ROAD_DIRECTORY); int len = strlen(dirBuf); @@ -273,6 +274,7 @@ BOOL RoadOptions::OnInitDialog() ++it; continue; } + 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/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..3ca23283ca 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(texture_name) >= ARRAY_SIZE(defaultDecalName), "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(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 eae8ffc250..3630c227c6 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(m_filePath) >= ARRAY_SIZE(W3D_DIR_PATH), "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(m_filePath) >= ARRAY_SIZE(TGA_DIR_PATH), "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(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)); @@ -232,6 +235,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { + 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)); @@ -253,6 +257,7 @@ char const * GameFileClass::Set_Name( char const *filename ) if( fileType == FILE_TYPE_W3D ) { + 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)); @@ -260,6 +265,7 @@ char const * GameFileClass::Set_Name( char const *filename ) else if( isImageFileType(fileType) ) { + 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 861182155c..e3c98a434c 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(dirBuf) >= ARRAY_SIZE(ROAD_DIRECTORY), "Incorrect array size"); strcpy(dirBuf, ROAD_DIRECTORY); int len = strlen(dirBuf); @@ -273,6 +274,7 @@ BOOL RoadOptions::OnInitDialog() ++it; continue; } + 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));