engine: fix buffer overflow in Sys_PrintLog
This commit is contained in:
parent
fb7f57cf6a
commit
4420ffd49e
1 changed files with 5 additions and 2 deletions
|
@ -297,6 +297,7 @@ void Sys_PrintLog( const char *pMsg )
|
||||||
const struct tm *crt_tm;
|
const struct tm *crt_tm;
|
||||||
char logtime[32] = "";
|
char logtime[32] = "";
|
||||||
static char lastchar;
|
static char lastchar;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
time( &crt_time );
|
time( &crt_time );
|
||||||
crt_tm = localtime( &crt_time );
|
crt_tm = localtime( &crt_time );
|
||||||
|
@ -307,10 +308,12 @@ void Sys_PrintLog( const char *pMsg )
|
||||||
// spew to stdout
|
// spew to stdout
|
||||||
Sys_PrintStdout( logtime, pMsg );
|
Sys_PrintStdout( logtime, pMsg );
|
||||||
|
|
||||||
|
len = Q_strlen( pMsg );
|
||||||
|
|
||||||
if( !s_ld.logfile )
|
if( !s_ld.logfile )
|
||||||
{
|
{
|
||||||
// save last char to detect when line was not ended
|
// save last char to detect when line was not ended
|
||||||
lastchar = pMsg[Q_strlen( pMsg ) - 1];
|
lastchar = len > 0 ? pMsg[len - 1] : 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +321,7 @@ void Sys_PrintLog( const char *pMsg )
|
||||||
strftime( logtime, sizeof( logtime ), "[%Y:%m:%d|%H:%M:%S] ", crt_tm ); //full time
|
strftime( logtime, sizeof( logtime ), "[%Y:%m:%d|%H:%M:%S] ", crt_tm ); //full time
|
||||||
|
|
||||||
// save last char to detect when line was not ended
|
// save last char to detect when line was not ended
|
||||||
lastchar = pMsg[Q_strlen( pMsg ) - 1];
|
lastchar = len > 0 ? pMsg[len - 1] : 0;
|
||||||
|
|
||||||
Sys_PrintLogfile( s_ld.logfileno, logtime, pMsg, false );
|
Sys_PrintLogfile( s_ld.logfileno, logtime, pMsg, false );
|
||||||
Sys_FlushLogfile();
|
Sys_FlushLogfile();
|
||||||
|
|
Loading…
Add table
Reference in a new issue