mirror of
https://github.com/dhewm/dhewm3-sdk.git
synced 2024-11-24 21:41:23 +00:00
Fix -Wformat-security warnings - thanks James Addison!
This is based on https://github.com/dhewm/dhewm3/pull/500 by https://github.com/jayaddison See also https://github.com/blendogames/quadrilateralcowboy/pull/4
This commit is contained in:
parent
46d22b885d
commit
c9f841d058
12 changed files with 41 additions and 40 deletions
|
@ -1222,7 +1222,7 @@ bool idGameLocal::NextMap( void ) {
|
|||
int i;
|
||||
|
||||
if ( !g_mapCycle.GetString()[0] ) {
|
||||
Printf( common->GetLanguageDict()->GetString( "#str_04294" ) );
|
||||
Printf( "%s", common->GetLanguageDict()->GetString( "#str_04294" ) );
|
||||
return false;
|
||||
}
|
||||
if ( fileSystem->ReadFile( g_mapCycle.GetString(), NULL, NULL ) < 0 ) {
|
||||
|
|
|
@ -734,7 +734,7 @@ void idGameLocal::NetworkEventWarning( const entityNetEvent_t *event, const char
|
|||
va_end( argptr );
|
||||
idStr::Append( buf, sizeof(buf), "\n" );
|
||||
|
||||
common->DWarning( buf );
|
||||
common->DWarning( "%s", buf );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -2847,10 +2847,10 @@ void idMultiplayerGame::PrintMessageEvent( int to, msg_evt_t evt, int parm1, int
|
|||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04289" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
|
||||
break;
|
||||
case MSG_VOTE:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04288" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04288" ) );
|
||||
break;
|
||||
case MSG_SUDDENDEATH:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04287" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04287" ) );
|
||||
break;
|
||||
case MSG_FORCEREADY:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04286" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
|
||||
|
@ -2862,7 +2862,7 @@ void idMultiplayerGame::PrintMessageEvent( int to, msg_evt_t evt, int parm1, int
|
|||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04285" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
|
||||
break;
|
||||
case MSG_TIMELIMIT:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04284" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04284" ) );
|
||||
break;
|
||||
case MSG_FRAGLIMIT:
|
||||
if ( gameLocal.gameType == GAME_LASTMAN ) {
|
||||
|
@ -2877,7 +2877,7 @@ void idMultiplayerGame::PrintMessageEvent( int to, msg_evt_t evt, int parm1, int
|
|||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04280" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ), parm2 ? common->GetLanguageDict()->GetString( "#str_02500" ) : common->GetLanguageDict()->GetString( "#str_02499" ) );
|
||||
break;
|
||||
case MSG_HOLYSHIT:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_06732" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_06732" ) );
|
||||
break;
|
||||
#ifdef CTF
|
||||
case MSG_POINTLIMIT:
|
||||
|
@ -2903,9 +2903,9 @@ void idMultiplayerGame::PrintMessageEvent( int to, msg_evt_t evt, int parm1, int
|
|||
break;
|
||||
|
||||
if ( gameLocal.GetLocalPlayer()->team != parm1 ) {
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_11103" ) ); // your team
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_11103" ) ); // your team
|
||||
} else {
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_11104" ) ); // enemy
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_11104" ) ); // enemy
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -3262,7 +3262,7 @@ void idMultiplayerGame::ClientStartVote( int clientNum, const char *_voteString
|
|||
}
|
||||
|
||||
voteString = _voteString;
|
||||
AddChatLine( va( common->GetLanguageDict()->GetString( "#str_04279" ), gameLocal.userInfo[ clientNum ].GetString( "ui_name" ) ) );
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04279" ), gameLocal.userInfo[ clientNum ].GetString( "ui_name" ) );
|
||||
gameSoundWorld->PlayShaderDirectly( GlobalSoundStrings[ SND_VOTE ] );
|
||||
if ( clientNum == gameLocal.localClientNum ) {
|
||||
voted = true;
|
||||
|
@ -3302,14 +3302,14 @@ void idMultiplayerGame::ClientUpdateVote( vote_result_t status, int yesCount, in
|
|||
|
||||
switch ( status ) {
|
||||
case VOTE_FAILED:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04278" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04278" ) );
|
||||
gameSoundWorld->PlayShaderDirectly( GlobalSoundStrings[ SND_VOTE_FAILED ] );
|
||||
if ( gameLocal.isClient ) {
|
||||
vote = VOTE_NONE;
|
||||
}
|
||||
break;
|
||||
case VOTE_PASSED:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04277" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04277" ) );
|
||||
gameSoundWorld->PlayShaderDirectly( GlobalSoundStrings[ SND_VOTE_PASSED ] );
|
||||
break;
|
||||
case VOTE_RESET:
|
||||
|
@ -3318,7 +3318,7 @@ void idMultiplayerGame::ClientUpdateVote( vote_result_t status, int yesCount, in
|
|||
}
|
||||
break;
|
||||
case VOTE_ABORTED:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04276" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04276" ) );
|
||||
if ( gameLocal.isClient ) {
|
||||
vote = VOTE_NONE;
|
||||
}
|
||||
|
@ -3856,7 +3856,7 @@ void idMultiplayerGame::ToggleSpectate( void ) {
|
|||
if ( gameLocal.serverInfo.GetBool( "si_spectators" ) ) {
|
||||
cvarSystem->SetCVarString( "ui_spectate", "Spectate" );
|
||||
} else {
|
||||
gameLocal.mpGame.AddChatLine( common->GetLanguageDict()->GetString( "#str_06747" ) );
|
||||
gameLocal.mpGame.AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_06747" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -691,7 +691,7 @@ Cmd_AddChatLine_f
|
|||
==================
|
||||
*/
|
||||
static void Cmd_AddChatLine_f( const idCmdArgs &args ) {
|
||||
gameLocal.mpGame.AddChatLine( args.Argv( 1 ) );
|
||||
gameLocal.mpGame.AddChatLine( "%s", args.Argv( 1 ) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1294,7 +1294,7 @@ static void PrintFloat( float f ) {
|
|||
buf[i] = ' ';
|
||||
}
|
||||
buf[i] = '\0';
|
||||
gameLocal.Printf( buf );
|
||||
gameLocal.Printf( "%s", buf );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -817,7 +817,7 @@ void idThread::Error( const char *fmt, ... ) const {
|
|||
vsprintf( text, fmt, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
interpreter.Error( text );
|
||||
interpreter.Error( "%s", text );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -833,7 +833,7 @@ void idThread::Warning( const char *fmt, ... ) const {
|
|||
vsprintf( text, fmt, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
interpreter.Warning( text );
|
||||
interpreter.Warning( "%s", text );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1098,7 +1098,7 @@ bool idGameLocal::NextMap( void ) {
|
|||
int i;
|
||||
|
||||
if ( !g_mapCycle.GetString()[0] ) {
|
||||
Printf( common->GetLanguageDict()->GetString( "#str_04294" ) );
|
||||
Printf( "%s", common->GetLanguageDict()->GetString( "#str_04294" ) );
|
||||
return false;
|
||||
}
|
||||
if ( fileSystem->ReadFile( g_mapCycle.GetString(), NULL, NULL ) < 0 ) {
|
||||
|
|
|
@ -720,7 +720,7 @@ void idGameLocal::NetworkEventWarning( const entityNetEvent_t *event, const char
|
|||
va_end( argptr );
|
||||
idStr::Append( buf, sizeof(buf), "\n" );
|
||||
|
||||
common->DWarning( buf );
|
||||
common->DWarning( "%s", buf );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -554,11 +554,12 @@ const char *idMultiplayerGame::GameTime() {
|
|||
ms = 0;
|
||||
}
|
||||
|
||||
s = ms / 1000;
|
||||
m = s / 60;
|
||||
s -= m * 60;
|
||||
t = s / 10;
|
||||
s -= t * 10;
|
||||
s = ms / 1000; // => s <= 2 147 483 (INT_MAX / 1000)
|
||||
m = s / 60; // => m <= 35 791
|
||||
s -= m * 60; // => s < 60
|
||||
t = s / 10; // => t < 6
|
||||
s -= t * 10; // => s < 10
|
||||
// writing <= 5 for m + 3 bytes for ":ts" + 1 byte for \0 => 16 bytes is enough
|
||||
|
||||
sprintf( buff, "%i:%i%i", m, t, s );
|
||||
}
|
||||
|
@ -2221,10 +2222,10 @@ void idMultiplayerGame::PrintMessageEvent( int to, msg_evt_t evt, int parm1, int
|
|||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04289" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
|
||||
break;
|
||||
case MSG_VOTE:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04288" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04288" ) );
|
||||
break;
|
||||
case MSG_SUDDENDEATH:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04287" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04287" ) );
|
||||
break;
|
||||
case MSG_FORCEREADY:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04286" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
|
||||
|
@ -2236,7 +2237,7 @@ void idMultiplayerGame::PrintMessageEvent( int to, msg_evt_t evt, int parm1, int
|
|||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04285" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
|
||||
break;
|
||||
case MSG_TIMELIMIT:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04284" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04284" ) );
|
||||
break;
|
||||
case MSG_FRAGLIMIT:
|
||||
if ( gameLocal.gameType == GAME_LASTMAN ) {
|
||||
|
@ -2251,7 +2252,7 @@ void idMultiplayerGame::PrintMessageEvent( int to, msg_evt_t evt, int parm1, int
|
|||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04280" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ), parm2 ? common->GetLanguageDict()->GetString( "#str_02500" ) : common->GetLanguageDict()->GetString( "#str_02499" ) );
|
||||
break;
|
||||
case MSG_HOLYSHIT:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_06732" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_06732" ) );
|
||||
break;
|
||||
default:
|
||||
gameLocal.DPrintf( "PrintMessageEvent: unknown message type %d\n", evt );
|
||||
|
@ -2570,7 +2571,7 @@ void idMultiplayerGame::ClientStartVote( int clientNum, const char *_voteString
|
|||
}
|
||||
|
||||
voteString = _voteString;
|
||||
AddChatLine( va( common->GetLanguageDict()->GetString( "#str_04279" ), gameLocal.userInfo[ clientNum ].GetString( "ui_name" ) ) );
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04279" ), gameLocal.userInfo[ clientNum ].GetString( "ui_name" ) );
|
||||
gameSoundWorld->PlayShaderDirectly( GlobalSoundStrings[ SND_VOTE ] );
|
||||
if ( clientNum == gameLocal.localClientNum ) {
|
||||
voted = true;
|
||||
|
@ -2610,14 +2611,14 @@ void idMultiplayerGame::ClientUpdateVote( vote_result_t status, int yesCount, in
|
|||
|
||||
switch ( status ) {
|
||||
case VOTE_FAILED:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04278" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04278" ) );
|
||||
gameSoundWorld->PlayShaderDirectly( GlobalSoundStrings[ SND_VOTE_FAILED ] );
|
||||
if ( gameLocal.isClient ) {
|
||||
vote = VOTE_NONE;
|
||||
}
|
||||
break;
|
||||
case VOTE_PASSED:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04277" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04277" ) );
|
||||
gameSoundWorld->PlayShaderDirectly( GlobalSoundStrings[ SND_VOTE_PASSED ] );
|
||||
break;
|
||||
case VOTE_RESET:
|
||||
|
@ -2626,7 +2627,7 @@ void idMultiplayerGame::ClientUpdateVote( vote_result_t status, int yesCount, in
|
|||
}
|
||||
break;
|
||||
case VOTE_ABORTED:
|
||||
AddChatLine( common->GetLanguageDict()->GetString( "#str_04276" ) );
|
||||
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04276" ) );
|
||||
if ( gameLocal.isClient ) {
|
||||
vote = VOTE_NONE;
|
||||
}
|
||||
|
@ -3122,7 +3123,7 @@ void idMultiplayerGame::ToggleSpectate( void ) {
|
|||
if ( gameLocal.serverInfo.GetBool( "si_spectators" ) ) {
|
||||
cvarSystem->SetCVarString( "ui_spectate", "Spectate" );
|
||||
} else {
|
||||
gameLocal.mpGame.AddChatLine( common->GetLanguageDict()->GetString( "#str_06747" ) );
|
||||
gameLocal.mpGame.AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_06747" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -626,7 +626,7 @@ Cmd_AddChatLine_f
|
|||
==================
|
||||
*/
|
||||
static void Cmd_AddChatLine_f( const idCmdArgs &args ) {
|
||||
gameLocal.mpGame.AddChatLine( args.Argv( 1 ) );
|
||||
gameLocal.mpGame.AddChatLine( "%s", args.Argv( 1 ) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1229,7 +1229,7 @@ static void PrintFloat( float f ) {
|
|||
buf[i] = ' ';
|
||||
}
|
||||
buf[i] = '\0';
|
||||
gameLocal.Printf( buf );
|
||||
gameLocal.Printf( "%s", buf );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -795,7 +795,7 @@ void idThread::Error( const char *fmt, ... ) const {
|
|||
vsprintf( text, fmt, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
interpreter.Error( text );
|
||||
interpreter.Error( "%s", text );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -811,7 +811,7 @@ void idThread::Warning( const char *fmt, ... ) const {
|
|||
vsprintf( text, fmt, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
interpreter.Warning( text );
|
||||
interpreter.Warning( "%s", text );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -326,7 +326,7 @@ void idParser::Error( const char *str, ... ) const {
|
|||
vsprintf(text, str, ap);
|
||||
va_end(ap);
|
||||
if ( idParser::scriptstack ) {
|
||||
idParser::scriptstack->Error( text );
|
||||
idParser::scriptstack->Error( "%s", text );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ void idParser::Warning( const char *str, ... ) const {
|
|||
vsprintf(text, str, ap);
|
||||
va_end(ap);
|
||||
if ( idParser::scriptstack ) {
|
||||
idParser::scriptstack->Warning( text );
|
||||
idParser::scriptstack->Warning( "%s", text );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ PrintClocks
|
|||
void PrintClocks( const char *string, int dataCount, int clocks, int otherClocks = 0 ) {
|
||||
int i;
|
||||
|
||||
idLib::common->Printf( string );
|
||||
idLib::common->Printf( "%s", string );
|
||||
for ( i = idStr::LengthWithoutColors(string); i < 48; i++ ) {
|
||||
idLib::common->Printf(" ");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue