@@ -192,7 +192,7 @@ static const char *getCurrentTimeString(void)
192
192
static const char *getCurrentTickString (void )
193
193
{
194
194
static char TheTickString[32 ];
195
- sprintf (TheTickString, " (T=%08lx)" ,::GetTickCount ());
195
+ snprintf (TheTickString, ARRAY_SIZE (TheTickString) , " (T=%08lx)" ,::GetTickCount ());
196
196
return TheTickString;
197
197
}
198
198
@@ -385,14 +385,20 @@ void DebugInit(int flags)
385
385
strcat (theLogFileNamePrev, gAppPrefix );
386
386
strcat (theLogFileNamePrev, DEBUG_FILE_NAME_PREV);
387
387
if (rts::ClientInstance::getInstanceId () > 1u )
388
- sprintf (theLogFileNamePrev + strlen (theLogFileNamePrev), " _Instance%.2u" , rts::ClientInstance::getInstanceId ());
388
+ {
389
+ size_t offset = strlen (theLogFileNamePrev);
390
+ snprintf (theLogFileNamePrev + offset, ARRAY_SIZE (theLogFileNamePrev) - offset, " _Instance%.2u" , rts::ClientInstance::getInstanceId ());
391
+ }
389
392
strcat (theLogFileNamePrev, " .txt" );
390
393
391
394
strcpy (theLogFileName, dirbuf);
392
395
strcat (theLogFileName, gAppPrefix );
393
396
strcat (theLogFileName, DEBUG_FILE_NAME);
394
397
if (rts::ClientInstance::getInstanceId () > 1u )
395
- sprintf (theLogFileName + strlen (theLogFileName), " _Instance%.2u" , rts::ClientInstance::getInstanceId ());
398
+ {
399
+ size_t offset = strlen (theLogFileNamePrev);
400
+ snprintf (theLogFileName + offset, ARRAY_SIZE (theLogFileName) - offset, " _Instance%.2u" , rts::ClientInstance::getInstanceId ());
401
+ }
396
402
strcat (theLogFileName, " .txt" );
397
403
398
404
remove (theLogFileNamePrev);
@@ -428,7 +434,8 @@ void DebugLog(const char *format, ...)
428
434
429
435
va_list args;
430
436
va_start (args, format);
431
- vsprintf (theBuffer + strlen (theBuffer), format, args);
437
+ size_t offset = strlen (theBuffer);
438
+ vsnprintf (theBuffer + offset, ARRAY_SIZE (theBuffer) - offset, format, args);
432
439
va_end (args);
433
440
434
441
if (strlen (theBuffer) >= sizeof (theBuffer))
@@ -454,7 +461,7 @@ void DebugLogRaw(const char *format, ...)
454
461
455
462
va_list args;
456
463
va_start (args, format);
457
- vsprintf (theBuffer, format, args);
464
+ vsnprintf (theBuffer, ARRAY_SIZE (theBuffer) , format, args);
458
465
va_end (args);
459
466
460
467
if (strlen (theBuffer) >= sizeof (theBuffer))
0 commit comments