diff --git a/Core/GameEngine/Source/Common/System/Debug.cpp b/Core/GameEngine/Source/Common/System/Debug.cpp index 88a65e228f..55dcdcd65f 100644 --- a/Core/GameEngine/Source/Common/System/Debug.cpp +++ b/Core/GameEngine/Source/Common/System/Debug.cpp @@ -388,24 +388,24 @@ void DebugInit(int flags) } strcpy(theLogFileNamePrev, dirbuf); - strcat(theLogFileNamePrev, gAppPrefix); - strcat(theLogFileNamePrev, DEBUG_FILE_NAME_PREV); + strlcat(theLogFileNamePrev, gAppPrefix, ARRAY_SIZE(theLogFileNamePrev)); + strlcat(theLogFileNamePrev, DEBUG_FILE_NAME_PREV, ARRAY_SIZE(theLogFileNamePrev)); if (rts::ClientInstance::getInstanceId() > 1u) { size_t offset = strlen(theLogFileNamePrev); snprintf(theLogFileNamePrev + offset, ARRAY_SIZE(theLogFileNamePrev) - offset, "_Instance%.2u", rts::ClientInstance::getInstanceId()); } - strcat(theLogFileNamePrev, ".txt"); + strlcat(theLogFileNamePrev, ".txt", ARRAY_SIZE(theLogFileNamePrev)); strcpy(theLogFileName, dirbuf); - strcat(theLogFileName, gAppPrefix); - strcat(theLogFileName, DEBUG_FILE_NAME); + strlcat(theLogFileName, gAppPrefix, ARRAY_SIZE(theLogFileNamePrev)); + strlcat(theLogFileName, DEBUG_FILE_NAME, ARRAY_SIZE(theLogFileNamePrev)); if (rts::ClientInstance::getInstanceId() > 1u) { size_t offset = strlen(theLogFileName); snprintf(theLogFileName + offset, ARRAY_SIZE(theLogFileName) - offset, "_Instance%.2u", rts::ClientInstance::getInstanceId()); } - strcat(theLogFileName, ".txt"); + strlcat(theLogFileName, ".txt", ARRAY_SIZE(theLogFileNamePrev)); remove(theLogFileNamePrev); rename(theLogFileName, theLogFileNamePrev); @@ -509,7 +509,7 @@ void DebugCrash(const char *format, ...) char theCrashBuffer[ LARGE_BUFFER ]; prepBuffer(theCrashBuffer); - strcat(theCrashBuffer, "ASSERTION FAILURE: "); + strlcat(theCrashBuffer, "ASSERTION FAILURE: ", ARRAY_SIZE(theCrashBuffer)); va_list arg; va_start(arg, format); @@ -538,7 +538,7 @@ void DebugCrash(const char *format, ...) #endif } - strcat(theCrashBuffer, "\n\nAbort->exception; Retry->debugger; Ignore->continue"); + strlcat(theCrashBuffer, "\n\nAbort->exception; Retry->debugger; Ignore->continue", ARRAY_SIZE(theCrashBuffer)); const int result = doCrashBox(theCrashBuffer, useLogging); @@ -737,9 +737,9 @@ void ReleaseCrash(const char *reason) } strcpy(prevbuf, TheGlobalData->getPath_UserData().str()); - strcat(prevbuf, RELEASECRASH_FILE_NAME_PREV); + strlcat(prevbuf, RELEASECRASH_FILE_NAME_PREV, ARRAY_SIZE(prevbuf)); strcpy(curbuf, TheGlobalData->getPath_UserData().str()); - strcat(curbuf, RELEASECRASH_FILE_NAME); + strlcat(curbuf, RELEASECRASH_FILE_NAME, ARRAY_SIZE(curbuf)); remove(prevbuf); rename(curbuf, prevbuf); @@ -826,9 +826,9 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m) char curbuf[ _MAX_PATH ]; strcpy(prevbuf, TheGlobalData->getPath_UserData().str()); - strcat(prevbuf, RELEASECRASH_FILE_NAME_PREV); + strlcat(prevbuf, RELEASECRASH_FILE_NAME_PREV, ARRAY_SIZE(prevbuf)); strcpy(curbuf, TheGlobalData->getPath_UserData().str()); - strcat(curbuf, RELEASECRASH_FILE_NAME); + strlcat(curbuf, RELEASECRASH_FILE_NAME, ARRAY_SIZE(curbuf)); remove(prevbuf); rename(curbuf, prevbuf); diff --git a/Core/GameEngine/Source/Common/System/GameMemory.cpp b/Core/GameEngine/Source/Common/System/GameMemory.cpp index 81d70b9d55..8fcf71b138 100644 --- a/Core/GameEngine/Source/Common/System/GameMemory.cpp +++ b/Core/GameEngine/Source/Common/System/GameMemory.cpp @@ -2976,7 +2976,7 @@ void MemoryPoolFactory::memoryPoolUsageReport( const char* filename, FILE *appen { char tmp[256]; strcpy(tmp,filename); - strcat(tmp,".csv"); + strlcat(tmp, ".csv", ARRAY_SIZE(tmp)); perfStatsFile = fopen(tmp, "w"); } else diff --git a/Core/GameEngine/Source/Common/System/GameMemoryInit.cpp b/Core/GameEngine/Source/Common/System/GameMemoryInit.cpp index 3f559fbdd0..7a1b0de948 100644 --- a/Core/GameEngine/Source/Common/System/GameMemoryInit.cpp +++ b/Core/GameEngine/Source/Common/System/GameMemoryInit.cpp @@ -123,7 +123,7 @@ void userMemoryManagerInitPools() } --pEnd; } - strcat(buf, "\\Data\\INI\\MemoryPools.ini"); + strlcat(buf, "\\Data\\INI\\MemoryPools.ini", ARRAY_SIZE(buf)); FILE* fp = fopen(buf, "r"); if (fp) diff --git a/Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp b/Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp index 0136f44882..2f0589fa4c 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp @@ -257,8 +257,8 @@ int HCompressedAnimClass::Load_W3D(ChunkLoadClass & cload) cload.Close_Chunk(); strcpy(Name,aheader.HierarchyName); - strcat(Name,"."); - strcat(Name,aheader.Name); + strlcat(Name, ".", ARRAY_SIZE(Name)); + strlcat(Name, aheader.Name, ARRAY_SIZE(Name)); // TSS chasing crash bug 05/26/99 WWASSERT(HierarchyName != NULL); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp b/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp index 352e56d35b..fb4b04d070 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp @@ -234,8 +234,8 @@ bool HModelDefClass::read_connection(ChunkLoadClass & cload,HmdlNodeDefStruct * } strcpy(node->RenderObjName,ModelName); - strcat(node->RenderObjName,"."); - strcat(node->RenderObjName,con.RenderObjName); + strlcat(node->RenderObjName, ".", ARRAY_SIZE(node->RenderObjName)); + strlcat(node->RenderObjName, con.RenderObjName, ARRAY_SIZE(node->RenderObjName)); if (pre30) { if (con.PivotIdx == 65535) { diff --git a/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp b/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp index 38c7e8a3e0..81659faabf 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp @@ -570,6 +570,6 @@ static const char * Make_W3D_Filename (const char *w3d_name) if (dot) *dot = 0; strlwr(buffer); - strcat(buffer, ".w3d"); + strlcat(buffer, ".w3d", ARRAY_SIZE(buffer)); return buffer; } diff --git a/Core/Libraries/Source/WWVegas/WWDownload/FTP.CPP b/Core/Libraries/Source/WWVegas/WWDownload/FTP.CPP index 2cea001161..36296fa335 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/FTP.CPP +++ b/Core/Libraries/Source/WWVegas/WWDownload/FTP.CPP @@ -36,6 +36,7 @@ #include #include #include +#include //#include "wlib/wstring.h" #include "stringex.h" @@ -141,7 +142,7 @@ static bool Use_Non_Blocking_Mode(void) if ((regRetval!=ERROR_SUCCESS) || (type != REG_DWORD)) return(TRUE); - return(bool(value)); + return bool(value); } @@ -679,7 +680,7 @@ HRESULT Cftp::FindFile( LPCSTR szRemoteFileName, int * piSize ) _splitpath( szRemoteFileName, NULL, m_szRemoteFilePath+strlen(m_szRemoteFilePath), m_szRemoteFileName, ext ); - strcat( m_szRemoteFileName, ext ); + strlcat(m_szRemoteFileName, ext, ARRAY_SIZE(m_szRemoteFileName)); for( i = 0; i < (int)strlen( m_szRemoteFilePath ); i++ ) { @@ -1723,11 +1724,11 @@ HRESULT Cftp::FileRecoveryPosition( LPCSTR szLocalFileName, LPCSTR szRegistryRo strcpy( regkey, szRegistryRoot ); if( regkey[ strlen( regkey ) - 1 ] != '\\' ) { - strcat( regkey, "\\Download" ); + strlcat(regkey, "\\Download", ARRAY_SIZE(regkey)); } else { - strcat( regkey, "Download" ); + strlcat(regkey, "Download", ARRAY_SIZE(regkey)); } if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, (LPCTSTR)regkey, diff --git a/Core/Libraries/Source/WWVegas/WWLib/Except.cpp b/Core/Libraries/Source/WWVegas/WWLib/Except.cpp index 8829a550ec..6de15adbb5 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/Except.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/Except.cpp @@ -224,7 +224,7 @@ char const * Last_Error_Text(void) *=============================================================================================*/ static void Add_Txt (char const *txt) { - if (strlen(ExceptionText) + strlen(txt) < 65535) { + if (strlen(ExceptionText) + strlen(txt) < ARRAY_SIZE(ExceptionText) - 1) { strcat(ExceptionText, txt); } #if (0) @@ -653,15 +653,15 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) for (int c = 0 ; c < 32 ; c++) { if (IsBadReadPtr(eip_ptr, 1)) { - strcat(scrap, "?? "); + strlcat(scrap, "?? ", ARRAY_SIZE(scrap)); } else { sprintf(bytestr, "%02X ", *eip_ptr); - strcat(scrap, bytestr); + strlcat(scrap, bytestr, ARRAY_SIZE(scrap)); } eip_ptr++; } - strcat(scrap, "\r\n\r\n"); + strlcat(scrap, "\r\n\r\n", ARRAY_SIZE(scrap)); Add_Txt(scrap); /* @@ -677,14 +677,14 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) ** The stack contents cannot be read so just print up question marks. */ sprintf(scrap, "%p: ", static_cast(stackptr)); - strcat(scrap, "????????\r\n"); + strlcat(scrap, "????????\r\n", ARRAY_SIZE(scrap)); } else { /* ** If this stack address is in our memory space then try to match it with a code symbol. */ if (IsBadCodePtr((FARPROC)*stackptr)) { sprintf(scrap, "%p: %08lX ", static_cast(stackptr), *stackptr); - strcat(scrap, "DATA_PTR\r\n"); + strlcat(scrap, "DATA_PTR\r\n", ARRAY_SIZE(scrap)); } else { sprintf(scrap, "%p: %08lX", static_cast(stackptr), *stackptr); @@ -697,12 +697,12 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) if (_SymGetSymFromAddr != NULL && _SymGetSymFromAddr (GetCurrentProcess(), *stackptr, &displacement, symptr)) { char symbuf[256]; sprintf(symbuf, " - %s + %08X", symptr->Name, displacement); - strcat(scrap, symbuf); + strlcat(scrap, symbuf, ARRAY_SIZE(scrap)); } } else { - strcat (scrap, " *"); + strlcat(scrap, " *", ARRAY_SIZE(scrap)); } - strcat (scrap, "\r\n"); + strlcat(scrap, "\r\n", ARRAY_SIZE(scrap)); } } Add_Txt(scrap); diff --git a/Core/Libraries/Source/WWVegas/WWLib/registry.cpp b/Core/Libraries/Source/WWVegas/WWLib/registry.cpp index cabbd36243..d5680ee7ed 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/registry.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/registry.cpp @@ -386,7 +386,7 @@ void RegistryClass::Save_Registry_Values(HKEY key, char *path, INIClass *ini) */ case REG_DWORD: strcpy(save_name, "DWORD_"); - strcat(save_name, value_name); + strlcat(save_name, value_name, ARRAY_SIZE(save_name)); ini->Put_Int(path, save_name, *((unsigned long*)data)); break; @@ -395,7 +395,7 @@ void RegistryClass::Save_Registry_Values(HKEY key, char *path, INIClass *ini) */ case REG_SZ: strcpy(save_name, "STRING_"); - strcat(save_name, value_name); + strlcat(save_name, value_name, ARRAY_SIZE(save_name)); ini->Put_String(path, save_name, (char*)data); break; @@ -404,7 +404,7 @@ void RegistryClass::Save_Registry_Values(HKEY key, char *path, INIClass *ini) */ case REG_BINARY: strcpy(save_name, "BIN_"); - strcat(save_name, value_name); + strlcat(save_name, value_name, ARRAY_SIZE(save_name)); ini->Put_UUBlock(path, save_name, (char*)data, data_size); break; @@ -471,8 +471,8 @@ void RegistryClass::Save_Registry_Tree(char *path, INIClass *ini) */ char new_key_path[512]; strcpy(new_key_path, path); - strcat(new_key_path, "\\"); - strcat(new_key_path, name); + strlcat(new_key_path, "\\", ARRAY_SIZE(new_key_path)); + strlcat(new_key_path, name, ARRAY_SIZE(new_key_path)); unsigned long num_subs = 0; unsigned long num_values = 0; @@ -567,7 +567,7 @@ void RegistryClass::Load_Registry(const char *filename, char *old_path, char *ne strcpy(path, new_path); char *cut = strstr(section_name, old_path); if (cut) { - strcat(path, cut + old_path_len); + strlcat(path, cut + old_path_len, ARRAY_SIZE(path)); } /* @@ -694,8 +694,8 @@ void RegistryClass::Delete_Registry_Tree(char *path) */ char new_key_path[512]; strcpy(new_key_path, path); - strcat(new_key_path, "\\"); - strcat(new_key_path, name); + strlcat(new_key_path, "\\", ARRAY_SIZE(new_key_path)); + strlcat(new_key_path, name, ARRAY_SIZE(new_key_path)); unsigned long num_subs = 0; unsigned long num_values = 0; diff --git a/Core/Libraries/Source/debug/debug_debug.cpp b/Core/Libraries/Source/debug/debug_debug.cpp index a2fbc3b696..9aeb7ec4cd 100644 --- a/Core/Libraries/Source/debug/debug_debug.cpp +++ b/Core/Libraries/Source/debug/debug_debug.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include // needed for placement new prototype // a little dummy variable that makes the linker actually include @@ -347,7 +348,7 @@ bool Debug::AssertDone(void) "time being (stops logging this assertion as well)."; char *help=(char *)DebugAllocMemory(ioBuffer[curType].used+strlen(addInfo)+1); strcpy(help,ioBuffer[curType].buffer+82); - strcat(help,addInfo); + strlcat(help, addInfo, ARRAY_SIZE(help)); // First hit? Then do a stack trace if (curFrameEntry->hits==1) @@ -611,7 +612,7 @@ bool Debug::CrashDone(bool die) #endif char *help=(char *)DebugAllocMemory(ioBuffer[curType].used+strlen(addInfo)+1); strcpy(help,ioBuffer[curType].buffer+82); - strcat(help,addInfo); + strlcat(help, addInfo, ARRAY_SIZE(help)); // First hit? Then do a stack trace if (curFrameEntry->hits==1) diff --git a/Core/Libraries/Source/debug/debug_io_flat.cpp b/Core/Libraries/Source/debug/debug_io_flat.cpp index 196a0892aa..80c6ff3a62 100644 --- a/Core/Libraries/Source/debug/debug_io_flat.cpp +++ b/Core/Libraries/Source/debug/debug_io_flat.cpp @@ -29,6 +29,7 @@ #include "_pch.h" #include "stringex.h" #include +#include #include // needed for placement new prototype DebugIOFlat::OutputStream::OutputStream(const char *filename, unsigned maxSize): @@ -94,7 +95,7 @@ void DebugIOFlat::OutputStream::Delete(const char *path) if (++run) wsprintf(help+strlen(help),"(%i)%s",run,ext); else - strcat(help,ext); + strlcat(help, ext, ARRAY_SIZE(help)); if (CopyFile(m_fileName,help,TRUE)) break; if (GetLastError()!=ERROR_FILE_EXISTS) diff --git a/Core/Libraries/Source/profile/profile_highlevel.cpp b/Core/Libraries/Source/profile/profile_highlevel.cpp index f091529789..566cb8cbcf 100644 --- a/Core/Libraries/Source/profile/profile_highlevel.cpp +++ b/Core/Libraries/Source/profile/profile_highlevel.cpp @@ -29,6 +29,7 @@ #include "_pch.h" #include "stringex.h" #include +#include #include // our own fast critical section diff --git a/Core/Tools/ImagePacker/CMakeLists.txt b/Core/Tools/ImagePacker/CMakeLists.txt index eb944eda28..c71eefca56 100644 --- a/Core/Tools/ImagePacker/CMakeLists.txt +++ b/Core/Tools/ImagePacker/CMakeLists.txt @@ -29,6 +29,7 @@ target_link_libraries(corei_imagepacker INTERFACE comctl32 core_debug core_profile + core_wwcommon dbghelplib imm32 vfw32 diff --git a/Core/Tools/ImagePacker/Source/ImagePacker.cpp b/Core/Tools/ImagePacker/Source/ImagePacker.cpp index 3796bbcdd4..42c815a4ff 100644 --- a/Core/Tools/ImagePacker/Source/ImagePacker.cpp +++ b/Core/Tools/ImagePacker/Source/ImagePacker.cpp @@ -44,6 +44,7 @@ #include #include #include +#include // USER INCLUDES ////////////////////////////////////////////////////////////// #include "stringex.h" @@ -1186,8 +1187,8 @@ Bool ImagePacker::process( void ) CreateDirectory( m_outputDirectory, NULL ); // subdir of output directory based on output image name - strcat( m_outputDirectory, m_outputFile ); - strcat( m_outputDirectory, "\\" ); + strlcat(m_outputDirectory, m_outputFile, ARRAY_SIZE(m_outputDirectory)); + strlcat(m_outputDirectory, "\\", ARRAY_SIZE(m_outputDirectory)); // // check for existing images in the output directory ... if we have diff --git a/Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp b/Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp index 3d944516e3..c76e57d98c 100644 --- a/Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp +++ b/Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp @@ -40,6 +40,7 @@ // SYSTEM INCLUDES //////////////////////////////////////////////////////////// #include #include +#include // USER INCLUDES ////////////////////////////////////////////////////////////// #include "ImagePacker.h" @@ -127,7 +128,7 @@ BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, // set the current directory in the top label GetCurrentDirectory( _MAX_PATH, buffer ); if( buffer[ strlen( buffer ) - 1 ] != '\\' ) - strcat( buffer, "\\" ); + strlcat(buffer, "\\", ARRAY_SIZE(buffer)); SetDlgItemText( hWndDialog, STATIC_CURRENT_DIR, buffer ); // load the drive box @@ -262,7 +263,7 @@ BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, // construct new direcotry name and update status text GetCurrentDirectory( _MAX_PATH, buffer ); if( buffer[ strlen( buffer ) - 1 ] != '\\' ) - strcat( buffer, "\\" ); + strlcat(buffer, "\\", ARRAY_SIZE(buffer)); SetDlgItemText( hWndDialog, STATIC_CURRENT_DIR, buffer ); EnableWindow( GetDlgItem( hWndDialog, BUTTON_ADD ), FALSE ); @@ -353,7 +354,7 @@ BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, // construct new direcotry name and update status text GetCurrentDirectory( _MAX_PATH, buffer ); if( buffer[ strlen( buffer ) - 1 ] != '\\' ) - strcat( buffer, "\\" ); + strlcat(buffer, "\\", ARRAY_SIZE(buffer)); SetDlgItemText( hWndDialog, STATIC_CURRENT_DIR, buffer ); EnableWindow( GetDlgItem( hWndDialog, BUTTON_ADD ), FALSE ); diff --git a/Core/Tools/W3DView/AnimReportPage.cpp b/Core/Tools/W3DView/AnimReportPage.cpp index 5435dbfc42..1b5af2f3ce 100644 --- a/Core/Tools/W3DView/AnimReportPage.cpp +++ b/Core/Tools/W3DView/AnimReportPage.cpp @@ -187,7 +187,7 @@ int CAnimReportPage::FindItem (const char *item_name) return m_AnimReport.FindItem(&lvfi); } -void CAnimReportPage::MakeChannelStr (int bone_idx, HAnimClass *hanim, char *channels) +void CAnimReportPage::MakeChannelStr (int bone_idx, HAnimClass *hanim, char channels[6]) { if (hanim->Has_X_Translation(bone_idx)) strcat(channels, "X"); diff --git a/Core/Tools/W3DView/AnimReportPage.h b/Core/Tools/W3DView/AnimReportPage.h index 74f9b96df3..914a57df3d 100644 --- a/Core/Tools/W3DView/AnimReportPage.h +++ b/Core/Tools/W3DView/AnimReportPage.h @@ -60,7 +60,7 @@ class CAnimReportPage : public CPropertyPage protected: void FillListControl (void); int FindItem (const char *item_name); - void MakeChannelStr (int bone_idx, HAnimClass *hanim, char *channels); + void MakeChannelStr(int bone_idx, HAnimClass* hanim, char channels[6]); CAdvancedAnimSheet *m_Sheet; diff --git a/Core/Tools/W3DView/GraphicView.cpp b/Core/Tools/W3DView/GraphicView.cpp index bb31526a1d..9ddeb97c89 100644 --- a/Core/Tools/W3DView/GraphicView.cpp +++ b/Core/Tools/W3DView/GraphicView.cpp @@ -1327,7 +1327,7 @@ CGraphicView::Load_Default_Dat (void) } // Concat the default.dat filename onto the path - ::strcat (filename, "\\default.dat"); + strlcat(filename, "\\default.dat", ARRAY_SIZE(filename)); // Does the file exist in the directory? if (::GetFileAttributes (filename) != 0xFFFFFFFF) { diff --git a/Core/Tools/W3DView/MainFrm.cpp b/Core/Tools/W3DView/MainFrm.cpp index ce8035a5a2..e27917e65f 100644 --- a/Core/Tools/W3DView/MainFrm.cpp +++ b/Core/Tools/W3DView/MainFrm.cpp @@ -687,7 +687,7 @@ CMainFrame::WindowProc // Concat the default.dat filename onto the path TCHAR full_path[MAX_PATH]; - ::strcat (filename, "\\settings"); + strlcat (filename, "\\settings", ARRAY_SIZE(filename)); ::wsprintf (full_path, "%s%d.dat", filename, (LOWORD(wParam) - IDM_SETTINGS1) + 1); // Does the file exist in the directory? diff --git a/Core/Tools/W3DView/W3DViewDoc.cpp b/Core/Tools/W3DView/W3DViewDoc.cpp index 19bd7530db..9c6fc5707d 100644 --- a/Core/Tools/W3DView/W3DViewDoc.cpp +++ b/Core/Tools/W3DView/W3DViewDoc.cpp @@ -1532,7 +1532,7 @@ CW3DViewDoc::SaveSettings if (szPath[::lstrlen (szPath)-1] != '\\') { // Ensure the path is directory delimited - ::strcat (szPath, "\\"); + strlcat(szPath, "\\", ARRAY_SIZE(szPath)); } // Prepend the filename with its new path diff --git a/Generals/Code/GameEngine/Source/Common/INI/INI.cpp b/Generals/Code/GameEngine/Source/Common/INI/INI.cpp index 5fdd096676..2b9fb9ce07 100644 --- a/Generals/Code/GameEngine/Source/Common/INI/INI.cpp +++ b/Generals/Code/GameEngine/Source/Common/INI/INI.cpp @@ -790,8 +790,8 @@ AsciiString INI::getNextQuotedAsciiString() if (strlen(token) > 1 && token[1] != '\t') { - strcat(buff, " "); - strcat(buff, token); + strlcat(buff, " ", ARRAY_SIZE(buff)); + strlcat(buff, token, ARRAY_SIZE(buff)); } else { Int buflen=strlen(buff); @@ -832,9 +832,9 @@ AsciiString INI::getNextAsciiString() if (strlen(token) > 1 && token[1] != '\t') { - strcat(buff, " "); + strlcat(buff, " ", ARRAY_SIZE(buff)); } - strcat(buff, token); + strlcat(buff, token, ARRAY_SIZE(buff)); result.set(buff); } } diff --git a/Generals/Code/GameEngine/Source/Common/PerfTimer.cpp b/Generals/Code/GameEngine/Source/Common/PerfTimer.cpp index c8912ef73d..d427b6fd01 100644 --- a/Generals/Code/GameEngine/Source/Common/PerfTimer.cpp +++ b/Generals/Code/GameEngine/Source/Common/PerfTimer.cpp @@ -273,7 +273,7 @@ void PerfGather::reset() char tmp[256]; strcpy(tmp, s_buf); - strcat(tmp, ".csv"); + strlcat(tmp, ".csv", ARRAY_SIZE(tmp)); s_perfStatsFile = fopen(tmp, "w"); s_perfDumpOptions = options; diff --git a/Generals/Code/GameEngine/Source/Common/System/StackDump.cpp b/Generals/Code/GameEngine/Source/Common/System/StackDump.cpp index 7e8d58b62f..669264aa22 100644 --- a/Generals/Code/GameEngine/Source/Common/System/StackDump.cpp +++ b/Generals/Code/GameEngine/Source/Common/System/StackDump.cpp @@ -616,7 +616,7 @@ void DumpExceptionInfo( unsigned int u, EXCEPTION_POINTERS* e_info ) else { sprintf (bytestr, "%02X ", *eip_ptr); - strcat (scrap, bytestr); + strlcat(scrap, bytestr, ARRAY_SIZE(scrap)); } eip_ptr++; } diff --git a/Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp b/Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp index e97e15edaf..496bdf224f 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp @@ -2063,7 +2063,7 @@ Parameter *Parameter::ReadParameter(DataChunkInput &file) char newName[256]; strcpy(oldName, pParm->m_string.str()); strcpy(newName, "GLA"); - strcat(newName, oldName+strlen("Fundamentalist")); + strlcat(newName, oldName+strlen("Fundamentalist"), ARRAY_SIZE(newName)); pParm->m_string.set(newName); DEBUG_LOG(("Changing Script Ref from %s to %s", oldName, newName)); } diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBridgeBuffer.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBridgeBuffer.cpp index d96364cb71..693129dd39 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBridgeBuffer.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBridgeBuffer.cpp @@ -237,11 +237,11 @@ Bool W3DBridge::load(BodyDamageType curDamageState) char right[_MAX_PATH]; strcpy(left, modelName); - strcat(left, ".BRIDGE_LEFT"); + strlcat(left, ".BRIDGE_LEFT", ARRAY_SIZE(left)); strcpy(section, modelName); - strcat(section, ".BRIDGE_SPAN"); + strlcat(section, ".BRIDGE_SPAN", ARRAY_SIZE(section)); strcpy(right, modelName); - strcat(right, ".BRIDGE_RIGHT"); + strlcat(right, ".BRIDGE_RIGHT", ARRAY_SIZE(right)); m_bridgeTexture = pMgr->Get_Texture(textureFile, MIP_LEVELS_3); m_leftMtx.Make_Identity(); diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp index ed0dd771aa..7a23fc3d1e 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp @@ -2900,7 +2900,7 @@ void W3DDisplay::takeScreenShot(void) sprintf( leafname, "%s%.3d.bmp", "sshot", frame_number++); #endif strcpy(pathname, TheGlobalData->getPath_UserData().str()); - strcat(pathname, leafname); + strlcat(pathname, leafname, ARRAY_SIZE(pathname)); if (_access( pathname, 0 ) == -1) done = true; } diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp index d75fc31008..8b61540156 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp @@ -172,14 +172,14 @@ char const * GameFileClass::Set_Name( char const *filename ) { strcpy( m_filePath, W3D_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } else if( isImageFileType(fileType) ) { strcpy( m_filePath, TGA_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } else @@ -197,14 +197,14 @@ char const * GameFileClass::Set_Name( char const *filename ) { strcpy( m_filePath, LEGACY_W3D_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } else if( isImageFileType(fileType) ) { strcpy( m_filePath, LEGACY_TGA_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } @@ -223,14 +223,14 @@ char const * GameFileClass::Set_Name( char const *filename ) { strcpy( m_filePath, TEST_W3D_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } else if( isImageFileType(fileType) ) { strcpy( m_filePath, TEST_TGA_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } @@ -247,14 +247,14 @@ char const * GameFileClass::Set_Name( char const *filename ) { sprintf(m_filePath,USER_W3D_DIR_PATH, TheGlobalData->getPath_UserData().str()); //strcpy( m_filePath, USER_W3D_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } if( isImageFileType(fileType) ) { sprintf(m_filePath,USER_TGA_DIR_PATH, TheGlobalData->getPath_UserData().str()); //strcpy( m_filePath, USER_TGA_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } @@ -271,7 +271,7 @@ char const * GameFileClass::Set_Name( char const *filename ) { sprintf(m_filePath,MAP_PREVIEW_DIR_PATH, TheGlobalData->getPath_UserData().str()); //strcpy( m_filePath, USER_TGA_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } @@ -287,7 +287,7 @@ char const * GameFileClass::Set_Name( char const *filename ) { static const char *localizedPathFormat = "Data/%s/Art/Textures/"; sprintf(m_filePath,localizedPathFormat, GetRegistryLanguage().str()); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hmorphanim.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/hmorphanim.cpp index ca25a66d09..8214610364 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hmorphanim.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/hmorphanim.cpp @@ -552,8 +552,8 @@ int HMorphAnimClass::Load_W3D(ChunkLoadClass & cload) strlcpy(AnimName,header.Name,sizeof(AnimName)); strlcpy(HierarchyName,header.HierarchyName,sizeof(HierarchyName)); strcpy(Name,HierarchyName); - strcat(Name,"."); - strcat(Name,AnimName); + strlcat(Name, ".", ARRAY_SIZE(Name)); + strlcat(Name, AnimName, ARRAY_SIZE(Name)); HTreeClass * base_pose = WW3DAssetManager::Get_Instance()->Get_HTree(HierarchyName); if (base_pose == NULL) { diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hrawanim.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/hrawanim.cpp index cf0398f0b5..ae95dfc976 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/hrawanim.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/hrawanim.cpp @@ -212,8 +212,8 @@ int HRawAnimClass::Load_W3D(ChunkLoadClass & cload) } strcpy(Name,aheader.HierarchyName); - strcat(Name,"."); - strcat(Name,aheader.Name); + strlcat(Name, ".", ARRAY_SIZE(Name)); + strlcat(Name, aheader.Name, ARRAY_SIZE(Name)); // TSS chasing crash bug 05/26/99 WWASSERT(HierarchyName != NULL); diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshgeometry.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshgeometry.cpp index 27d8d5567e..221307965e 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshgeometry.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshgeometry.cpp @@ -1604,9 +1604,9 @@ WW3DErrorType MeshGeometryClass::Load_W3D(ChunkLoadClass & cload) if (strlen(header.ContainerName) > 0) { strcpy(tmpname,header.ContainerName); - strcat(tmpname,"."); + strcat(tmpname, "."); } - strcat(tmpname,header.MeshName); + strcat(tmpname, header.MeshName); Set_Name(tmpname); diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmdlio.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmdlio.cpp index d950ec4d04..d50b7ebda3 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmdlio.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmdlio.cpp @@ -275,9 +275,9 @@ WW3DErrorType MeshModelClass::Load_W3D(ChunkLoadClass & cload) if (strlen(context->Header.ContainerName) > 0) { strcpy(tmpname,context->Header.ContainerName); - strcat(tmpname,"."); + strcat(tmpname, "."); } - strcat(tmpname,context->Header.MeshName); + strcat(tmpname, context->Header.MeshName); Set_Name(tmpname); diff --git a/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp b/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp index 770001592c..7d73dea209 100644 --- a/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp +++ b/Generals/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp @@ -948,8 +948,8 @@ HWND InitListboxPropertiesDialog( GameWindow *window ) sprintf(percentages,"%d",listData->columnWidthPercentage[0]); for(Int i = 1; i < listData->columns; i++ ) { - strcat(percentages,","); - strcat(percentages,itoa(listData->columnWidthPercentage[i],tempStr,10)); + strlcat(percentages, ",", ARRAY_SIZE(percentages)); + strlcat(percentages, itoa(listData->columnWidthPercentage[i],tempStr,10), ARRAY_SIZE(percentages)); } SetDlgItemText(dialog,EDIT_COLUMN_PERCENT,percentages); diff --git a/Generals/Code/Tools/GUIEdit/Source/GUIEditWindowManager.cpp b/Generals/Code/Tools/GUIEdit/Source/GUIEditWindowManager.cpp index f26eb7428e..81f60d75e9 100644 --- a/Generals/Code/Tools/GUIEdit/Source/GUIEditWindowManager.cpp +++ b/Generals/Code/Tools/GUIEdit/Source/GUIEditWindowManager.cpp @@ -515,7 +515,7 @@ void GUIEditWindowManager::incrementName( GameWindow *window ) if( len == 0 ) { - strcat( name, "1" ); + strlcat(name, "1", ARRAY_SIZE(name)); goto cleanup; } @@ -586,7 +586,7 @@ void GUIEditWindowManager::incrementName( GameWindow *window ) { // no number at end, easy ... just append a number '1' - strcat( name, "1" ); + strlcat(name, "1", ARRAY_SIZE(name)); } diff --git a/Generals/Code/Tools/GUIEdit/Source/HierarchyView.cpp b/Generals/Code/Tools/GUIEdit/Source/HierarchyView.cpp index 59dc28e312..9a10111a27 100644 --- a/Generals/Code/Tools/GUIEdit/Source/HierarchyView.cpp +++ b/Generals/Code/Tools/GUIEdit/Source/HierarchyView.cpp @@ -877,8 +877,8 @@ char *HierarchyView::getWindowTreeName( GameWindow *window ) if( !instData->m_decoratedNameString.isEmpty() ) { - strcat( buffer, ": " ); - strcat( buffer, instData->m_decoratedNameString.str() ); + strlcat(buffer, ": ", ARRAY_SIZE(buffer)); + strlcat(buffer, instData->m_decoratedNameString.str(), ARRAY_SIZE(buffer)); } diff --git a/Generals/Code/Tools/GUIEdit/Source/Save.cpp b/Generals/Code/Tools/GUIEdit/Source/Save.cpp index ea99537a36..949f4ef1b4 100644 --- a/Generals/Code/Tools/GUIEdit/Source/Save.cpp +++ b/Generals/Code/Tools/GUIEdit/Source/Save.cpp @@ -230,10 +230,10 @@ static Bool saveStatus( GameWindow *window, FILE *fp, Int dataIndent ) // if this is an additional bit add a + if( bitWritten == TRUE ) - strcat( buffer, "+"); + strlcat(buffer, "+", ARRAY_SIZE(buffer)); // add status name - strcat( buffer, WindowStatusNames[ i ] ); + strlcat(buffer, WindowStatusNames[ i ], ARRAY_SIZE(buffer)); bitWritten = TRUE; } @@ -243,10 +243,10 @@ static Bool saveStatus( GameWindow *window, FILE *fp, Int dataIndent ) // if no bits written write NONE in the file if( bitWritten == FALSE ) - strcat( buffer, "NONE" ); + strlcat(buffer, "NONE", ARRAY_SIZE(buffer)); // complete line and write - strcat( buffer, ";\n" ); + strlcat(buffer, ";\n", ARRAY_SIZE(buffer)); writeBufferToFile( fp, buffer ); return TRUE; @@ -274,10 +274,10 @@ static Bool saveStyle( GameWindow *window, FILE *fp, Int dataIndent ) // if this is an additional bit add a + if( bitWritten == TRUE ) - strcat( buffer, "+"); + strlcat(buffer, "+", ARRAY_SIZE(buffer)); // add status name - strcat( buffer, WindowStyleNames[ i ] ); + strlcat(buffer, WindowStyleNames[ i ], ARRAY_SIZE(buffer)); bitWritten = TRUE; } @@ -287,10 +287,10 @@ static Bool saveStyle( GameWindow *window, FILE *fp, Int dataIndent ) // if no bits written write NONE in the file if( bitWritten == FALSE ) - strcat( buffer, "NONE" ); + strlcat(buffer, "NONE", ARRAY_SIZE(buffer)); // complete line and write - strcat( buffer, ";\n" ); + strlcat(buffer, ";\n", ARRAY_SIZE(buffer)); writeBufferToFile( fp, buffer ); return TRUE; @@ -1115,11 +1115,11 @@ void GUIEdit::validateNames( GameWindow *root, char *filename, Bool *valid ) if( strlen( filename ) + instData->m_decoratedNameString.getLength() >= MAX_WINDOW_NAME_LEN ) { - strcat( offendingNames, "[Too Long] " ); - strcat( offendingNames, filename ); - strcat( offendingNames, ":" ); - strcat( offendingNames, instData->m_decoratedNameString.str() ); - strcat( offendingNames, "\n"); + strlcat(offendingNames, "[Too Long] ", ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, filename, ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, ":", ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, instData->m_decoratedNameString.str(), ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, "\n", ARRAY_SIZE(offendingNames)); *valid = FALSE; } @@ -1129,11 +1129,11 @@ void GUIEdit::validateNames( GameWindow *root, char *filename, Bool *valid ) root, instData->m_decoratedNameString ) ) { - strcat( offendingNames, "[Duplicate] " ); - strcat( offendingNames, filename ); - strcat( offendingNames, ":" ); - strcat( offendingNames, instData->m_decoratedNameString.str() ); - strcat( offendingNames, "\n" ); + strlcat(offendingNames, "[Duplicate] ", ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, filename, ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, ":", ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, instData->m_decoratedNameString.str(), ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, "\n", ARRAY_SIZE(offendingNames)); *valid = FALSE; } diff --git a/Generals/Code/Tools/WorldBuilder/src/BuildList.cpp b/Generals/Code/Tools/WorldBuilder/src/BuildList.cpp index d47437e28d..831ad919f4 100644 --- a/Generals/Code/Tools/WorldBuilder/src/BuildList.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/BuildList.cpp @@ -756,9 +756,9 @@ void BuildList::OnExport() SidesInfo *pSide = TheSidesList->getSideInfo(m_curSide); Dict *d = TheSidesList->getSideInfo(m_curSide)->getDict(); AsciiString name = d->getAsciiString(TheKey_playerName); - strcat(curbuf, name.str()); - strcat(curbuf, "_BuildList"); - strcat(curbuf, ".ini"); + strlcat(curbuf, name.str(), ARRAY_SIZE(curbuf)); + strlcat(curbuf, "_BuildList", ARRAY_SIZE(curbuf)); + strlcat(curbuf, ".ini", ARRAY_SIZE(curbuf)); theLogFile = fopen(curbuf, "w"); if (theLogFile == NULL) diff --git a/Generals/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp b/Generals/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp index ea6b3d0d24..b8311dc864 100644 --- a/Generals/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp @@ -93,7 +93,7 @@ BOOL MeshMoldOptions::OnInitDialog() dirBuf[len] = 0; } strcpy(findBuf, dirBuf); - strcat(findBuf, "*.w3d"); + strlcat(findBuf, "*.w3d", ARRAY_SIZE(findBuf)); FilenameList filenameList; TheFileSystem->getFileListInDirectory(AsciiString(dirBuf), AsciiString("*.w3d"), filenameList, FALSE); diff --git a/Generals/Code/Tools/WorldBuilder/src/ObjectOptions.cpp b/Generals/Code/Tools/WorldBuilder/src/ObjectOptions.cpp index 463f0cbce2..d60794cc75 100644 --- a/Generals/Code/Tools/WorldBuilder/src/ObjectOptions.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/ObjectOptions.cpp @@ -290,7 +290,7 @@ BOOL ObjectOptions::OnInitDialog() dirBuf[len] = 0; } strcpy(findBuf, dirBuf); - strcat(findBuf, "*.*"); + strlcat(findBuf, "*.*", ARRAY_SIZE(findBuf)); FilenameList filenameList; TheFileSystem->getFileListInDirectory(AsciiString(dirBuf), AsciiString("*.w3d"), filenameList, FALSE); @@ -310,8 +310,8 @@ BOOL ObjectOptions::OnInitDialog() } strcpy(fileBuf, TEST_STRING); - strcat(fileBuf, "/"); - strcat(fileBuf, token.str()); + strlcat(fileBuf, "/", ARRAY_SIZE(findBuf)); + strlcat(fileBuf, token.str(), ARRAY_SIZE(findBuf)); for (i=strlen(fileBuf)-1; i>0; i--) { if (fileBuf[i] == '.') { // strip off .w3d file extension. diff --git a/Generals/Code/Tools/WorldBuilder/src/OpenMap.cpp b/Generals/Code/Tools/WorldBuilder/src/OpenMap.cpp index 97045445e9..8417ad50fc 100644 --- a/Generals/Code/Tools/WorldBuilder/src/OpenMap.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/OpenMap.cpp @@ -119,7 +119,7 @@ void OpenMap::populateMapListbox( Bool systemMaps ) else { strcpy(dirBuf, TheGlobalData->getPath_UserData().str()); - strcat(dirBuf, "Maps\\"); + strlcat(dirBuf, "Maps\\", ARRAY_SIZE(dirBuf)); } int len = strlen(dirBuf); @@ -132,7 +132,7 @@ void OpenMap::populateMapListbox( Bool systemMaps ) if (pList == NULL) return; pList->ResetContent(); strcpy(findBuf, dirBuf); - strcat(findBuf, "*.*"); + strlcat(findBuf, "*.*", ARRAY_SIZE(findBuf)); Bool found = false; @@ -146,10 +146,10 @@ void OpenMap::populateMapListbox( Bool systemMaps ) } strcpy(fileBuf, dirBuf); - strcat(fileBuf, findData.cFileName); - strcat(fileBuf, "\\"); - strcat(fileBuf, findData.cFileName); - strcat(fileBuf, ".map"); + strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(findBuf)); + strlcat(fileBuf, "\\", ARRAY_SIZE(findBuf)); + strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(findBuf)); + strlcat(fileBuf, ".map", ARRAY_SIZE(findBuf)); try { CFileStatus status; if (CFile::GetStatus(fileBuf, status)) { diff --git a/Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp b/Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp index a236622819..918e42976f 100644 --- a/Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/RoadOptions.cpp @@ -274,8 +274,8 @@ BOOL RoadOptions::OnInitDialog() continue; } strcpy(fileBuf, TEST_STRING); - strcat(fileBuf, "\\"); - strcat(fileBuf, filename.str()); + strlcat(fileBuf, "\\", ARRAY_SIZE(fileBuf)); + strlcat(fileBuf, filename.str(), ARRAY_SIZE(fileBuf)); addRoad(fileBuf, index, TVI_ROOT); index++; m_numberOfRoads++; diff --git a/Generals/Code/Tools/WorldBuilder/src/SaveMap.cpp b/Generals/Code/Tools/WorldBuilder/src/SaveMap.cpp index 162697f9de..cb70c42ccb 100644 --- a/Generals/Code/Tools/WorldBuilder/src/SaveMap.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/SaveMap.cpp @@ -139,7 +139,7 @@ void SaveMap::populateMapListbox( Bool systemMaps ) if (pList == NULL) return; pList->ResetContent(); strcpy(findBuf, dirBuf); - strcat(findBuf, "*.*"); + strlcat(findBuf, "*.*", ARRAY_SIZE(findBuf)); hFindFile = FindFirstFile(findBuf, &findData); if (hFindFile != INVALID_HANDLE_VALUE) { @@ -150,10 +150,10 @@ void SaveMap::populateMapListbox( Bool systemMaps ) continue; } strcpy(fileBuf, dirBuf); - strcat(fileBuf, findData.cFileName); - strcat(fileBuf, "\\"); - strcat(fileBuf, findData.cFileName); - strcat(fileBuf, ".map"); + strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(fileBuf)); + strlcat(fileBuf, "\\", ARRAY_SIZE(fileBuf)); + strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(fileBuf)); + strlcat(fileBuf, ".map", ARRAY_SIZE(fileBuf)); try { CFileStatus status; if (CFile::GetStatus(fileBuf, status)) { diff --git a/Generals/Code/Tools/WorldBuilder/src/WorldBuilder.cpp b/Generals/Code/Tools/WorldBuilder/src/WorldBuilder.cpp index 9d440098c8..fb897701ec 100644 --- a/Generals/Code/Tools/WorldBuilder/src/WorldBuilder.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/WorldBuilder.cpp @@ -353,10 +353,10 @@ BOOL CWorldBuilderApp::InitInstance() // srj sez: put INI into our user data folder, not the ap dir free((void*)m_pszProfileName); strcpy(buf, TheGlobalData->getPath_UserData().str()); - strcat(buf, "WorldBuilder.ini"); + strlcat(buf, "WorldBuilder.ini", ARRAY_SIZE(buf)); #else - strcat(buf, "//"); - strcat(buf, m_pszProfileName); + strlcat(buf, "//", ARRAY_SIZE(buf)); + strlcat(buf, m_pszProfileName, ARRAY_SIZE(buf)); free((void*)m_pszProfileName); #endif m_pszProfileName = (const char *)malloc(strlen(buf)+2); diff --git a/Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp b/Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp index b875fa5e5d..a4364d5f24 100644 --- a/Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp +++ b/Generals/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp @@ -426,7 +426,7 @@ AsciiString ConvertName(AsciiString name) char newName[256]; strcpy(oldName, name.str()); strcpy(newName, "GLA"); - strcat(newName, oldName+strlen("Fundamentalist")); + strlcat(newName, oldName+strlen("Fundamentalist"), ARRAY_SIZE(newName)); AsciiString swapName; swapName.set(newName); const ThingTemplate *tt = TheThingFactory->findTemplate(swapName); @@ -442,7 +442,7 @@ AsciiString ConvertFaction(AsciiString name) char newName[256]; strcpy(oldName, name.str()); strcpy(newName, "FactionGLA"); - strcat(newName, oldName+strlen("FactionFundamentalist")); + strlcat(newName, oldName+strlen("FactionFundamentalist"), ARRAY_SIZE(newName)); AsciiString swapName; swapName.set(newName); const PlayerTemplate* pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(swapName)); @@ -2119,8 +2119,8 @@ void CWorldBuilderDoc::OnDumpDocToText(void) char curbuf[ _MAX_PATH ]; strcpy(curbuf, dirbuf); - strcat(curbuf, m_strTitle); - strcat(curbuf, ".txt"); + strlcat(curbuf, m_strTitle, ARRAY_SIZE(curbuf)); + strlcat(curbuf, ".txt", ARRAY_SIZE(curbuf)); theLogFile = fopen(curbuf, "w"); if (theLogFile == NULL) diff --git a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp index f0f940f1dd..13e02c692b 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp @@ -782,8 +782,8 @@ AsciiString INI::getNextQuotedAsciiString() if (strlen(token) > 1 && token[1] != '\t') { - strcat(buff, " "); - strcat(buff, token); + strlcat(buff, " ", ARRAY_SIZE(buff)); + strlcat(buff, token, ARRAY_SIZE(buff)); } else { Int buflen=strlen(buff); @@ -824,9 +824,9 @@ AsciiString INI::getNextAsciiString() if (token) { if (strlen(token) > 1 && token[1] != '\t') { - strcat(buff, " "); + strlcat(buff, " ", ARRAY_SIZE(buff)); } - strcat(buff, token); + strlcat(buff, token, ARRAY_SIZE(buff)); result.set(buff); } else { Int len = strlen(buff); diff --git a/GeneralsMD/Code/GameEngine/Source/Common/PerfTimer.cpp b/GeneralsMD/Code/GameEngine/Source/Common/PerfTimer.cpp index 0da53ddcdd..72fc4837ca 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/PerfTimer.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/PerfTimer.cpp @@ -353,7 +353,7 @@ void PerfGather::reset() char tmp[256]; strcpy(tmp, s_buf); - strcat(tmp, ".csv"); + strlcat(tmp, ".csv", ARRAY_SIZE(tmp)); s_perfStatsFile = fopen(tmp, "w"); s_perfDumpOptions = options; diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp index b485a89a84..012f649a16 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/System/StackDump.cpp @@ -617,7 +617,7 @@ void DumpExceptionInfo( unsigned int u, EXCEPTION_POINTERS* e_info ) else { sprintf (bytestr, "%02X ", *eip_ptr); - strcat (scrap, bytestr); + strlcat(scrap, bytestr, ARRAY_SIZE(scrap)); } eip_ptr++; } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp index 657cc8cb77..a8b756760a 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp @@ -2138,7 +2138,7 @@ Parameter *Parameter::ReadParameter(DataChunkInput &file) char newName[256]; strcpy(oldName, pParm->m_string.str()); strcpy(newName, "GLA"); - strcat(newName, oldName+strlen("Fundamentalist")); + strlcat(newName, oldName+strlen("Fundamentalist"), ARRAY_SIZE(newName)); pParm->m_string.set(newName); DEBUG_LOG(("Changing Script Ref from %s to %s", oldName, newName)); } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBridgeBuffer.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBridgeBuffer.cpp index 8a2062cce1..fbb0111fd2 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBridgeBuffer.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBridgeBuffer.cpp @@ -237,11 +237,11 @@ Bool W3DBridge::load(BodyDamageType curDamageState) char right[_MAX_PATH]; strcpy(left, modelName); - strcat(left, ".BRIDGE_LEFT"); + strlcat(left, ".BRIDGE_LEFT", ARRAY_SIZE(left)); strcpy(section, modelName); - strcat(section, ".BRIDGE_SPAN"); + strlcat(section, ".BRIDGE_SPAN", ARRAY_SIZE(section)); strcpy(right, modelName); - strcat(right, ".BRIDGE_RIGHT"); + strlcat(right, ".BRIDGE_RIGHT", ARRAY_SIZE(right)); m_bridgeTexture = pMgr->Get_Texture(textureFile, MIP_LEVELS_3); m_leftMtx.Make_Identity(); diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp index 352b9d97c7..9de06ab757 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp @@ -3019,7 +3019,7 @@ void W3DDisplay::takeScreenShot(void) sprintf( leafname, "%s%.3d.bmp", "sshot", frame_number++); #endif strcpy(pathname, TheGlobalData->getPath_UserData().str()); - strcat(pathname, leafname); + strlcat(pathname, leafname, ARRAY_SIZE(pathname)); if (_access( pathname, 0 ) == -1) done = true; } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp index 4c9336143f..a4079ad8aa 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DFileSystem.cpp @@ -189,7 +189,7 @@ char const * GameFileClass::Set_Name( char const *filename ) { static const char *localizedPathFormat = "Data/%s/Art/W3D/"; sprintf(m_filePath,localizedPathFormat, GetRegistryLanguage().str()); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } @@ -198,7 +198,7 @@ char const * GameFileClass::Set_Name( char const *filename ) { static const char *localizedPathFormat = "Data/%s/Art/Textures/"; sprintf(m_filePath,localizedPathFormat, GetRegistryLanguage().str()); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } @@ -215,14 +215,14 @@ char const * GameFileClass::Set_Name( char const *filename ) { strcpy( m_filePath, W3D_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } else if( isImageFileType(fileType) ) { strcpy( m_filePath, TGA_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } else @@ -243,14 +243,14 @@ char const * GameFileClass::Set_Name( char const *filename ) { strcpy( m_filePath, LEGACY_W3D_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } else if( isImageFileType(fileType) ) { strcpy( m_filePath, LEGACY_TGA_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } @@ -271,14 +271,14 @@ char const * GameFileClass::Set_Name( char const *filename ) { strcpy( m_filePath, TEST_W3D_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } else if( isImageFileType(fileType) ) { strcpy( m_filePath, TEST_TGA_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } @@ -295,14 +295,14 @@ char const * GameFileClass::Set_Name( char const *filename ) { sprintf(m_filePath,USER_W3D_DIR_PATH, TheGlobalData->getPath_UserData().str()); //strcpy( m_filePath, USER_W3D_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } if( isImageFileType(fileType) ) { sprintf(m_filePath,USER_TGA_DIR_PATH, TheGlobalData->getPath_UserData().str()); //strcpy( m_filePath, USER_TGA_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } @@ -319,7 +319,7 @@ char const * GameFileClass::Set_Name( char const *filename ) { sprintf(m_filePath,MAP_PREVIEW_DIR_PATH, TheGlobalData->getPath_UserData().str()); //strcpy( m_filePath, USER_TGA_DIR_PATH ); - strcat( m_filePath, filename ); + strlcat(m_filePath, filename, ARRAY_SIZE(m_filePath)); } diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hmorphanim.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hmorphanim.cpp index be53ca5e63..03477b880d 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hmorphanim.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hmorphanim.cpp @@ -551,8 +551,8 @@ int HMorphAnimClass::Load_W3D(ChunkLoadClass & cload) strlcpy(AnimName,header.Name,sizeof(AnimName)); strlcpy(HierarchyName,header.HierarchyName,sizeof(HierarchyName)); strcpy(Name,HierarchyName); - strcat(Name,"."); - strcat(Name,AnimName); + strlcat(Name, ".", ARRAY_SIZE(Name)); + strlcat(Name, AnimName, ARRAY_SIZE(Name)); HTreeClass * base_pose = WW3DAssetManager::Get_Instance()->Get_HTree(HierarchyName); if (base_pose == NULL) { diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hrawanim.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hrawanim.cpp index 0a625a64ba..790abf043a 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hrawanim.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/hrawanim.cpp @@ -212,8 +212,8 @@ int HRawAnimClass::Load_W3D(ChunkLoadClass & cload) } strcpy(Name,aheader.HierarchyName); - strcat(Name,"."); - strcat(Name,aheader.Name); + strlcat(Name, ".", ARRAY_SIZE(Name)); + strlcat(Name, aheader.Name, ARRAY_SIZE(Name)); // TSS chasing crash bug 05/26/99 WWASSERT(HierarchyName != NULL); diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshgeometry.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshgeometry.cpp index bb609a1f5c..242f66da06 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshgeometry.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshgeometry.cpp @@ -1616,9 +1616,9 @@ WW3DErrorType MeshGeometryClass::Load_W3D(ChunkLoadClass & cload) if (strlen(header.ContainerName) > 0) { strcpy(tmpname,header.ContainerName); - strcat(tmpname,"."); + strcat(tmpname, "."); } - strcat(tmpname,header.MeshName); + strcat(tmpname, header.MeshName); Set_Name(tmpname); diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmdlio.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmdlio.cpp index b6dfc18e66..7eb0c93909 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmdlio.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmdlio.cpp @@ -275,9 +275,9 @@ WW3DErrorType MeshModelClass::Load_W3D(ChunkLoadClass & cload) if (strlen(context->Header.ContainerName) > 0) { strcpy(tmpname,context->Header.ContainerName); - strcat(tmpname,"."); + strcat(tmpname, "."); } - strcat(tmpname,context->Header.MeshName); + strcat(tmpname, context->Header.MeshName); Set_Name(tmpname); diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cpp index 2fd5e3f804..e23d4e4b44 100644 --- a/GeneralsMD/Code/Main/WinMain.cpp +++ b/GeneralsMD/Code/Main/WinMain.cpp @@ -837,7 +837,7 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, const char *fileName = "Install_Final.bmp"; static const char *localizedPathFormat = "Data/%s/"; sprintf(filePath,localizedPathFormat, GetRegistryLanguage().str()); - strcat( filePath, fileName ); + strlcat(filePath, fileName, ARRAY_SIZE(filePath)); FILE *fileImage = fopen(filePath, "r"); if (fileImage) { fclose(fileImage); diff --git a/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp b/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp index 882aa66618..569de7ba74 100644 --- a/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp +++ b/GeneralsMD/Code/Tools/GUIEdit/Source/Dialog Procedures/ListboxProperties.cpp @@ -948,8 +948,8 @@ HWND InitListboxPropertiesDialog( GameWindow *window ) sprintf(percentages,"%d",listData->columnWidthPercentage[0]); for(Int i = 1; i < listData->columns; i++ ) { - strcat(percentages,","); - strcat(percentages,itoa(listData->columnWidthPercentage[i],tempStr,10)); + strlcat(percentages, ",", ARRAY_SIZE(percentages)); + strlcat(percentages, itoa(listData->columnWidthPercentage[i],tempStr,10), ARRAY_SIZE(percentages)); } SetDlgItemText(dialog,EDIT_COLUMN_PERCENT,percentages); diff --git a/GeneralsMD/Code/Tools/GUIEdit/Source/GUIEditWindowManager.cpp b/GeneralsMD/Code/Tools/GUIEdit/Source/GUIEditWindowManager.cpp index 005c618f7b..43f00b40a0 100644 --- a/GeneralsMD/Code/Tools/GUIEdit/Source/GUIEditWindowManager.cpp +++ b/GeneralsMD/Code/Tools/GUIEdit/Source/GUIEditWindowManager.cpp @@ -515,7 +515,7 @@ void GUIEditWindowManager::incrementName( GameWindow *window ) if( len == 0 ) { - strcat( name, "1" ); + strlcat(name, "1", ARRAY_SIZE(name)); goto cleanup; } @@ -586,7 +586,7 @@ void GUIEditWindowManager::incrementName( GameWindow *window ) { // no number at end, easy ... just append a number '1' - strcat( name, "1" ); + strlcat(name, "1", ARRAY_SIZE(name)); } diff --git a/GeneralsMD/Code/Tools/GUIEdit/Source/HierarchyView.cpp b/GeneralsMD/Code/Tools/GUIEdit/Source/HierarchyView.cpp index 4cf2cc128b..e46cb28c75 100644 --- a/GeneralsMD/Code/Tools/GUIEdit/Source/HierarchyView.cpp +++ b/GeneralsMD/Code/Tools/GUIEdit/Source/HierarchyView.cpp @@ -891,8 +891,8 @@ char *HierarchyView::getWindowTreeName( GameWindow *window ) if( !instData->m_decoratedNameString.isEmpty() ) { - strcat( buffer, ": " ); - strcat( buffer, instData->m_decoratedNameString.str() ); + strlcat(buffer, ": ", ARRAY_SIZE(buffer)); + strlcat(buffer, instData->m_decoratedNameString.str(), ARRAY_SIZE(buffer)); } diff --git a/GeneralsMD/Code/Tools/GUIEdit/Source/Save.cpp b/GeneralsMD/Code/Tools/GUIEdit/Source/Save.cpp index 42f29d89c4..56111932eb 100644 --- a/GeneralsMD/Code/Tools/GUIEdit/Source/Save.cpp +++ b/GeneralsMD/Code/Tools/GUIEdit/Source/Save.cpp @@ -230,10 +230,10 @@ static Bool saveStatus( GameWindow *window, FILE *fp, Int dataIndent ) // if this is an additional bit add a + if( bitWritten == TRUE ) - strcat( buffer, "+"); + strlcat(buffer, "+", ARRAY_SIZE(buffer)); // add status name - strcat( buffer, WindowStatusNames[ i ] ); + strlcat(buffer, WindowStatusNames[ i ], ARRAY_SIZE(buffer)); bitWritten = TRUE; } @@ -243,10 +243,10 @@ static Bool saveStatus( GameWindow *window, FILE *fp, Int dataIndent ) // if no bits written write NONE in the file if( bitWritten == FALSE ) - strcat( buffer, "NONE" ); + strlcat(buffer, "NONE", ARRAY_SIZE(buffer)); // complete line and write - strcat( buffer, ";\n" ); + strlcat(buffer, ";\n", ARRAY_SIZE(buffer)); writeBufferToFile( fp, buffer ); return TRUE; @@ -274,10 +274,10 @@ static Bool saveStyle( GameWindow *window, FILE *fp, Int dataIndent ) // if this is an additional bit add a + if( bitWritten == TRUE ) - strcat( buffer, "+"); + strlcat(buffer, "+", ARRAY_SIZE(buffer)); // add status name - strcat( buffer, WindowStyleNames[ i ] ); + strlcat(buffer, WindowStyleNames[ i ], ARRAY_SIZE(buffer)); bitWritten = TRUE; } @@ -287,10 +287,10 @@ static Bool saveStyle( GameWindow *window, FILE *fp, Int dataIndent ) // if no bits written write NONE in the file if( bitWritten == FALSE ) - strcat( buffer, "NONE" ); + strlcat(buffer, "NONE", ARRAY_SIZE(buffer)); // complete line and write - strcat( buffer, ";\n" ); + strlcat(buffer, ";\n", ARRAY_SIZE(buffer)); writeBufferToFile( fp, buffer ); return TRUE; @@ -1115,11 +1115,11 @@ void GUIEdit::validateNames( GameWindow *root, char *filename, Bool *valid ) if( strlen( filename ) + instData->m_decoratedNameString.getLength() >= MAX_WINDOW_NAME_LEN ) { - strcat( offendingNames, "[Too Long] " ); - strcat( offendingNames, filename ); - strcat( offendingNames, ":" ); - strcat( offendingNames, instData->m_decoratedNameString.str() ); - strcat( offendingNames, "\n"); + strlcat(offendingNames, "[Too Long] ", ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, filename, ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, ":", ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, instData->m_decoratedNameString.str(), ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, "\n", ARRAY_SIZE(offendingNames)); *valid = FALSE; } @@ -1129,11 +1129,11 @@ void GUIEdit::validateNames( GameWindow *root, char *filename, Bool *valid ) root, instData->m_decoratedNameString ) ) { - strcat( offendingNames, "[Duplicate] " ); - strcat( offendingNames, filename ); - strcat( offendingNames, ":" ); - strcat( offendingNames, instData->m_decoratedNameString.str() ); - strcat( offendingNames, "\n" ); + strlcat(offendingNames, "[Duplicate] ", ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, filename, ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, ":", ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, instData->m_decoratedNameString.str(), ARRAY_SIZE(offendingNames)); + strlcat(offendingNames, "\n", ARRAY_SIZE(offendingNames)); *valid = FALSE; } diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/BuildList.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/BuildList.cpp index 7b20f601c0..3c9034a89a 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/BuildList.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/BuildList.cpp @@ -756,9 +756,9 @@ void BuildList::OnExport() SidesInfo *pSide = TheSidesList->getSideInfo(m_curSide); Dict *d = TheSidesList->getSideInfo(m_curSide)->getDict(); AsciiString name = d->getAsciiString(TheKey_playerName); - strcat(curbuf, name.str()); - strcat(curbuf, "_BuildList"); - strcat(curbuf, ".ini"); + strlcat(curbuf, name.str(), ARRAY_SIZE(curbuf)); + strlcat(curbuf, "_BuildList", ARRAY_SIZE(curbuf)); + strlcat(curbuf, ".ini", ARRAY_SIZE(curbuf)); theLogFile = fopen(curbuf, "w"); if (theLogFile == NULL) diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp index bbd6c110b0..666f1d655a 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/MeshMoldOptions.cpp @@ -93,7 +93,7 @@ BOOL MeshMoldOptions::OnInitDialog() dirBuf[len] = 0; } strcpy(findBuf, dirBuf); - strcat(findBuf, "*.w3d"); + strlcat(findBuf, "*.w3d", ARRAY_SIZE(findBuf)); FilenameList filenameList; TheFileSystem->getFileListInDirectory(AsciiString(dirBuf), AsciiString("*.w3d"), filenameList, FALSE); diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/ObjectOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/ObjectOptions.cpp index 3e5e4f2813..f7e5b7e471 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/ObjectOptions.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/ObjectOptions.cpp @@ -290,7 +290,7 @@ BOOL ObjectOptions::OnInitDialog() dirBuf[len] = 0; } strcpy(findBuf, dirBuf); - strcat(findBuf, "*.*"); + strlcat(findBuf, "*.*", ARRAY_SIZE(findBuf)); FilenameList filenameList; TheFileSystem->getFileListInDirectory(AsciiString(dirBuf), AsciiString("*.w3d"), filenameList, FALSE); @@ -310,8 +310,8 @@ BOOL ObjectOptions::OnInitDialog() } strcpy(fileBuf, TEST_STRING); - strcat(fileBuf, "/"); - strcat(fileBuf, token.str()); + strlcat(fileBuf, "/", ARRAY_SIZE(findBuf)); + strlcat(fileBuf, token.str(), ARRAY_SIZE(findBuf)); for (i=strlen(fileBuf)-1; i>0; i--) { if (fileBuf[i] == '.') { // strip off .w3d file extension. diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/OpenMap.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/OpenMap.cpp index e09dfafb70..4973d45c5f 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/OpenMap.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/OpenMap.cpp @@ -119,7 +119,7 @@ void OpenMap::populateMapListbox( Bool systemMaps ) else { strcpy(dirBuf, TheGlobalData->getPath_UserData().str()); - strcat(dirBuf, "Maps\\"); + strlcat(dirBuf, "Maps\\", ARRAY_SIZE(dirBuf)); } int len = strlen(dirBuf); @@ -132,7 +132,7 @@ void OpenMap::populateMapListbox( Bool systemMaps ) if (pList == NULL) return; pList->ResetContent(); strcpy(findBuf, dirBuf); - strcat(findBuf, "*.*"); + strlcat(findBuf, "*.*", ARRAY_SIZE(findBuf)); Bool found = false; @@ -146,10 +146,10 @@ void OpenMap::populateMapListbox( Bool systemMaps ) } strcpy(fileBuf, dirBuf); - strcat(fileBuf, findData.cFileName); - strcat(fileBuf, "\\"); - strcat(fileBuf, findData.cFileName); - strcat(fileBuf, ".map"); + strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(findBuf)); + strlcat(fileBuf, "\\", ARRAY_SIZE(findBuf)); + strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(findBuf)); + strlcat(fileBuf, ".map", ARRAY_SIZE(findBuf)); try { CFileStatus status; if (CFile::GetStatus(fileBuf, status)) { diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp index c6142d37c7..861182155c 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/RoadOptions.cpp @@ -274,8 +274,8 @@ BOOL RoadOptions::OnInitDialog() continue; } strcpy(fileBuf, TEST_STRING); - strcat(fileBuf, "\\"); - strcat(fileBuf, filename.str()); + strlcat(fileBuf, "\\", ARRAY_SIZE(fileBuf)); + strlcat(fileBuf, filename.str(), ARRAY_SIZE(fileBuf)); addRoad(fileBuf, index, TVI_ROOT); index++; m_numberOfRoads++; diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp index 4b6ca773ae..f7b18a277b 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/SaveMap.cpp @@ -139,7 +139,7 @@ void SaveMap::populateMapListbox( Bool systemMaps ) if (pList == NULL) return; pList->ResetContent(); strcpy(findBuf, dirBuf); - strcat(findBuf, "*.*"); + strlcat(findBuf, "*.*", ARRAY_SIZE(findBuf)); hFindFile = FindFirstFile(findBuf, &findData); if (hFindFile != INVALID_HANDLE_VALUE) { @@ -150,10 +150,10 @@ void SaveMap::populateMapListbox( Bool systemMaps ) continue; } strcpy(fileBuf, dirBuf); - strcat(fileBuf, findData.cFileName); - strcat(fileBuf, "\\"); - strcat(fileBuf, findData.cFileName); - strcat(fileBuf, ".map"); + strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(fileBuf)); + strlcat(fileBuf, "\\", ARRAY_SIZE(fileBuf)); + strlcat(fileBuf, findData.cFileName, ARRAY_SIZE(fileBuf)); + strlcat(fileBuf, ".map", ARRAY_SIZE(fileBuf)); try { CFileStatus status; if (CFile::GetStatus(fileBuf, status)) { diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilder.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilder.cpp index dead6bdcc3..0acb59714f 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilder.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilder.cpp @@ -366,10 +366,10 @@ BOOL CWorldBuilderApp::InitInstance() // srj sez: put INI into our user data folder, not the ap dir free((void*)m_pszProfileName); strcpy(buf, TheGlobalData->getPath_UserData().str()); - strcat(buf, "WorldBuilder.ini"); + strlcat(buf, "WorldBuilder.ini", ARRAY_SIZE(buf)); #else - strcat(buf, "//"); - strcat(buf, m_pszProfileName); + strlcat(buf, "//", ARRAY_SIZE(buf)); + strlcat(buf, m_pszProfileName, ARRAY_SIZE(buf)); free((void*)m_pszProfileName); #endif m_pszProfileName = (const char *)malloc(strlen(buf)+2); diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp index 69a15a01ca..52bed9d22c 100644 --- a/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp +++ b/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp @@ -457,7 +457,7 @@ AsciiString ConvertName(AsciiString name) char newName[256]; strcpy(oldName, name.str()); strcpy(newName, "GLA"); - strcat(newName, oldName+strlen("Fundamentalist")); + strlcat(newName, oldName+strlen("Fundamentalist"), ARRAY_SIZE(newName)); AsciiString swapName; swapName.set(newName); const ThingTemplate *tt = TheThingFactory->findTemplate(swapName); @@ -473,7 +473,7 @@ AsciiString ConvertFaction(AsciiString name) char newName[256]; strcpy(oldName, name.str()); strcpy(newName, "FactionGLA"); - strcat(newName, oldName+strlen("FactionFundamentalist")); + strlcat(newName, oldName+strlen("FactionFundamentalist"), ARRAY_SIZE(newName)); AsciiString swapName; swapName.set(newName); const PlayerTemplate* pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(swapName)); @@ -2176,8 +2176,8 @@ void CWorldBuilderDoc::OnDumpDocToText(void) char curbuf[ _MAX_PATH ]; strcpy(curbuf, dirbuf); - strcat(curbuf, m_strTitle); - strcat(curbuf, ".txt"); + strlcat(curbuf, m_strTitle, ARRAY_SIZE(curbuf)); + strlcat(curbuf, ".txt", ARRAY_SIZE(curbuf)); theLogFile = fopen(curbuf, "w"); if (theLogFile == NULL)