@@ -99,8 +99,8 @@ CybsLogError cybs_prepare_log(config cfg)
99
99
char szArchiveName[CYBS_MAX_PATH + 1 ];
100
100
101
101
get_formatted_time ( ARCHIVE_TIMESTAMP, szFormattedTime );
102
- sprintf (
103
- szArchiveName, " %s.%s" , cfg.logFilePath , szFormattedTime );
102
+ snprintf (
103
+ szArchiveName, sizeof (szArchiveName), " %s.%s" , cfg.logFilePath , szFormattedTime );
104
104
// TODO: test this, esp. on Linux. Not sure if the new name has to include the path on Linux. On Windows, it doesn't.
105
105
if (rename ( cfg.logFilePath , szArchiveName ))
106
106
{
@@ -487,8 +487,8 @@ void get_formatted_time( const char *szFormat, char *szDest )
487
487
488
488
SYSTEMTIME time ;
489
489
GetLocalTime ( &time );
490
- sprintf (
491
- szDest, szFormat, time .wYear , time .wMonth , time .wDay ,
490
+ snprintf (
491
+ szDest, sizeof (szDest), szFormat, time .wYear , time .wMonth , time .wDay ,
492
492
time .wHour , time .wMinute , time .wSecond , time .wMilliseconds );
493
493
#else
494
494
@@ -501,8 +501,8 @@ void get_formatted_time( const char *szFormat, char *szDest )
501
501
functions so this is not an issue. */
502
502
loc = localtime ( &clock );
503
503
504
- sprintf (
505
- szDest, szFormat, loc->tm_year + 1900 , loc->tm_mon + 1 , loc->tm_mday ,
504
+ snprintf (
505
+ szDest, sizeof (szDest), szFormat, loc->tm_year + 1900 , loc->tm_mon + 1 , loc->tm_mday ,
506
506
loc->tm_hour , loc->tm_min , loc->tm_sec );
507
507
508
508
#endif
0 commit comments