@@ -388,24 +388,24 @@ void DebugInit(int flags)
388388 }
389389
390390 strcpy (theLogFileNamePrev, dirbuf);
391- strcat (theLogFileNamePrev, gAppPrefix );
392- strcat (theLogFileNamePrev, DEBUG_FILE_NAME_PREV);
391+ strlcat (theLogFileNamePrev, gAppPrefix , ARRAY_SIZE (theLogFileNamePrev) );
392+ strlcat (theLogFileNamePrev, DEBUG_FILE_NAME_PREV, ARRAY_SIZE (theLogFileNamePrev) );
393393 if (rts::ClientInstance::getInstanceId () > 1u )
394394 {
395395 size_t offset = strlen (theLogFileNamePrev);
396396 snprintf (theLogFileNamePrev + offset, ARRAY_SIZE (theLogFileNamePrev) - offset, " _Instance%.2u" , rts::ClientInstance::getInstanceId ());
397397 }
398- strcat (theLogFileNamePrev, " .txt" );
398+ strlcat (theLogFileNamePrev, " .txt" , ARRAY_SIZE (theLogFileNamePrev) );
399399
400400 strcpy (theLogFileName, dirbuf);
401- strcat (theLogFileName, gAppPrefix );
402- strcat (theLogFileName, DEBUG_FILE_NAME);
401+ strlcat (theLogFileName, gAppPrefix , ARRAY_SIZE (theLogFileNamePrev) );
402+ strlcat (theLogFileName, DEBUG_FILE_NAME, ARRAY_SIZE (theLogFileNamePrev) );
403403 if (rts::ClientInstance::getInstanceId () > 1u )
404404 {
405405 size_t offset = strlen (theLogFileName);
406406 snprintf (theLogFileName + offset, ARRAY_SIZE (theLogFileName) - offset, " _Instance%.2u" , rts::ClientInstance::getInstanceId ());
407407 }
408- strcat (theLogFileName, " .txt" );
408+ strlcat (theLogFileName, " .txt" , ARRAY_SIZE (theLogFileNamePrev) );
409409
410410 remove (theLogFileNamePrev);
411411 rename (theLogFileName, theLogFileNamePrev);
@@ -509,7 +509,7 @@ void DebugCrash(const char *format, ...)
509509 char theCrashBuffer[ LARGE_BUFFER ];
510510
511511 prepBuffer (theCrashBuffer);
512- strcat (theCrashBuffer, " ASSERTION FAILURE: " );
512+ strlcat (theCrashBuffer, " ASSERTION FAILURE: " , ARRAY_SIZE (theCrashBuffer) );
513513
514514 va_list arg;
515515 va_start (arg, format);
@@ -538,7 +538,7 @@ void DebugCrash(const char *format, ...)
538538#endif
539539 }
540540
541- strcat (theCrashBuffer, " \n\n Abort->exception; Retry->debugger; Ignore->continue" );
541+ strlcat (theCrashBuffer, " \n\n Abort->exception; Retry->debugger; Ignore->continue" , ARRAY_SIZE (theCrashBuffer) );
542542
543543 const int result = doCrashBox (theCrashBuffer, useLogging);
544544
@@ -737,9 +737,9 @@ void ReleaseCrash(const char *reason)
737737 }
738738
739739 strcpy (prevbuf, TheGlobalData->getPath_UserData ().str ());
740- strcat (prevbuf, RELEASECRASH_FILE_NAME_PREV);
740+ strlcat (prevbuf, RELEASECRASH_FILE_NAME_PREV, ARRAY_SIZE (prevbuf) );
741741 strcpy (curbuf, TheGlobalData->getPath_UserData ().str ());
742- strcat (curbuf, RELEASECRASH_FILE_NAME);
742+ strlcat (curbuf, RELEASECRASH_FILE_NAME, ARRAY_SIZE (curbuf) );
743743
744744 remove (prevbuf);
745745 rename (curbuf, prevbuf);
@@ -826,9 +826,9 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m)
826826 char curbuf[ _MAX_PATH ];
827827
828828 strcpy (prevbuf, TheGlobalData->getPath_UserData ().str ());
829- strcat (prevbuf, RELEASECRASH_FILE_NAME_PREV);
829+ strlcat (prevbuf, RELEASECRASH_FILE_NAME_PREV, ARRAY_SIZE (prevbuf) );
830830 strcpy (curbuf, TheGlobalData->getPath_UserData ().str ());
831- strcat (curbuf, RELEASECRASH_FILE_NAME);
831+ strlcat (curbuf, RELEASECRASH_FILE_NAME, ARRAY_SIZE (curbuf) );
832832
833833 remove (prevbuf);
834834 rename (curbuf, prevbuf);
0 commit comments