Update sources to compile successfully with -Wformat-security compilation flag enabled

This commit is contained in:
James Addison 2022-12-17 23:23:01 +00:00
parent 86872eedc2
commit 2489c8a5e8
14 changed files with 59 additions and 59 deletions

View file

@ -137,7 +137,7 @@ const char *idCollisionModelManagerLocal::StringFromContents( const int contents
if ( length != 0 ) {
length += idStr::snPrintf( contentsString + length, sizeof( contentsString ) - length, "," );
}
length += idStr::snPrintf( contentsString + length, sizeof( contentsString ) - length, cm_contentsNameByIndex[i] );
length += idStr::snPrintf( contentsString + length, sizeof( contentsString ) - length, "%s", cm_contentsNameByIndex[i] );
}
}

View file

@ -1526,7 +1526,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 ) {

View file

@ -2823,60 +2823,60 @@ void idMultiplayerGame::PrintMessageEvent( int to, msg_evt_t evt, int parm1, int
switch ( evt ) {
case MSG_SUICIDE:
assert( parm1 >= 0 );
AddChatLine( common->GetLanguageDict()->GetString( "#str_04293" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04293" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
break;
case MSG_KILLED:
assert( parm1 >= 0 && parm2 >= 0 );
AddChatLine( common->GetLanguageDict()->GetString( "#str_04292" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) );
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04292" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) );
break;
case MSG_KILLEDTEAM:
assert( parm1 >= 0 && parm2 >= 0 );
AddChatLine( common->GetLanguageDict()->GetString( "#str_04291" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) );
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04291" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) );
break;
case MSG_TELEFRAGGED:
assert( parm1 >= 0 && parm2 >= 0 );
AddChatLine( common->GetLanguageDict()->GetString( "#str_04290" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) );
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04290" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) );
break;
case MSG_DIED:
assert( parm1 >= 0 );
AddChatLine( common->GetLanguageDict()->GetString( "#str_04289" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
AddChatLine( "%s", 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" ) );
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04286" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
if ( gameLocal.entities[ parm1 ] && gameLocal.entities[ parm1 ]->IsType( idPlayer::Type ) ) {
static_cast< idPlayer * >( gameLocal.entities[ parm1 ] )->forcedReady = true;
}
break;
case MSG_JOINEDSPEC:
AddChatLine( common->GetLanguageDict()->GetString( "#str_04285" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
AddChatLine( "%s", 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 ) {
AddChatLine( common->GetLanguageDict()->GetString( "#str_04283" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04283" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
} else if ( IsGametypeTeamBased() ) { /* CTF */
AddChatLine( common->GetLanguageDict()->GetString( "#str_04282" ), gameLocal.userInfo[ parm1 ].GetString( "ui_team" ) );
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04282" ), gameLocal.userInfo[ parm1 ].GetString( "ui_team" ) );
} else {
AddChatLine( common->GetLanguageDict()->GetString( "#str_04281" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04281" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ) );
}
break;
case MSG_JOINTEAM:
AddChatLine( common->GetLanguageDict()->GetString( "#str_04280" ), gameLocal.userInfo[ parm1 ].GetString( "ui_name" ), parm2 ? common->GetLanguageDict()->GetString( "#str_02500" ) : common->GetLanguageDict()->GetString( "#str_02499" ) );
AddChatLine( "%s", 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:
AddChatLine( common->GetLanguageDict()->GetString( "#str_11100" ), parm1 ? common->GetLanguageDict()->GetString( "#str_11110" ) : common->GetLanguageDict()->GetString( "#str_11111" ) );
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_11100" ), parm1 ? common->GetLanguageDict()->GetString( "#str_11110" ) : common->GetLanguageDict()->GetString( "#str_11111" ) );
break;
case MSG_FLAGTAKEN :
@ -2887,9 +2887,9 @@ void idMultiplayerGame::PrintMessageEvent( int to, msg_evt_t evt, int parm1, int
break;
if ( gameLocal.GetLocalPlayer()->team != parm1 ) {
AddChatLine( common->GetLanguageDict()->GetString( "#str_11101" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) ); // your team
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_11101" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) ); // your team
} else {
AddChatLine( common->GetLanguageDict()->GetString( "#str_11102" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) ); // enemy
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_11102" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) ); // enemy
}
break;
@ -2898,9 +2898,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;
@ -2910,12 +2910,12 @@ void idMultiplayerGame::PrintMessageEvent( int to, msg_evt_t evt, int parm1, int
if ( parm2 >= 0 && parm2 < MAX_CLIENTS ) {
if ( gameLocal.GetLocalPlayer()->team != parm1 ) {
AddChatLine( common->GetLanguageDict()->GetString( "#str_11120" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) ); // your team
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_11120" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) ); // your team
} else {
AddChatLine( common->GetLanguageDict()->GetString( "#str_11121" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) ); // enemy
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_11121" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) ); // enemy
}
} else {
AddChatLine( common->GetLanguageDict()->GetString( "#str_11105" ), parm1 ? common->GetLanguageDict()->GetString( "#str_11110" ) : common->GetLanguageDict()->GetString( "#str_11111" ) );
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_11105" ), parm1 ? common->GetLanguageDict()->GetString( "#str_11110" ) : common->GetLanguageDict()->GetString( "#str_11111" ) );
}
break;
@ -2927,16 +2927,16 @@ void idMultiplayerGame::PrintMessageEvent( int to, msg_evt_t evt, int parm1, int
break;
if ( gameLocal.GetLocalPlayer()->team != parm1 ) {
AddChatLine( common->GetLanguageDict()->GetString( "#str_11122" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) ); // your team
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_11122" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) ); // your team
} else {
AddChatLine( common->GetLanguageDict()->GetString( "#str_11123" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) ); // enemy
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_11123" ), gameLocal.userInfo[ parm2 ].GetString( "ui_name" ) ); // enemy
}
// AddChatLine( common->GetLanguageDict()->GetString( "#str_11106" ), parm1 ? common->GetLanguageDict()->GetString( "#str_11110" ) : common->GetLanguageDict()->GetString( "#str_11111" ) );
// AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_11106" ), parm1 ? common->GetLanguageDict()->GetString( "#str_11110" ) : common->GetLanguageDict()->GetString( "#str_11111" ) );
break;
case MSG_SCOREUPDATE:
AddChatLine( common->GetLanguageDict()->GetString( "#str_11107" ), parm1, parm2 );
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_11107" ), parm1, parm2 );
break;
#endif
default:
@ -3257,7 +3257,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( "%s", va( common->GetLanguageDict()->GetString( "#str_04279" ), gameLocal.userInfo[ clientNum ].GetString( "ui_name" ) ) );
gameSoundWorld->PlayShaderDirectly( GlobalSoundStrings[ SND_VOTE ] );
if ( clientNum == gameLocal.localClientNum ) {
voted = true;
@ -3297,14 +3297,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:
@ -3313,7 +3313,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;
}
@ -3851,7 +3851,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" ) );
}
}
}
@ -3905,7 +3905,7 @@ void idMultiplayerGame::ThrottleUserInfo( void ) {
if ( idStr::Icmp( gameLocal.userInfo[ gameLocal.localClientNum ].GetString( ThrottleVars[ i ] ),
cvarSystem->GetCVarString( ThrottleVars[ i ] ) ) ) {
if ( gameLocal.realClientTime < switchThrottle[ i ] ) {
AddChatLine( common->GetLanguageDict()->GetString( "#str_04299" ), common->GetLanguageDict()->GetString( ThrottleVarsInEnglish[ i ] ), ( switchThrottle[ i ] - gameLocal.time ) / 1000 + 1 );
AddChatLine( "%s", common->GetLanguageDict()->GetString( "#str_04299" ), common->GetLanguageDict()->GetString( ThrottleVarsInEnglish[ i ] ), ( switchThrottle[ i ] - gameLocal.time ) / 1000 + 1 );
cvarSystem->SetCVarString( ThrottleVars[ i ], gameLocal.userInfo[ gameLocal.localClientNum ].GetString( ThrottleVars[ i ] ) );
} else {
switchThrottle[ i ] = gameLocal.time + ThrottleDelay[ i ] * 1000;

View file

@ -714,7 +714,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 ) );
}
/*
@ -1316,7 +1316,7 @@ static void PrintFloat( float f ) {
buf[i] = ' ';
}
buf[i] = '\0';
gameLocal.Printf( buf );
gameLocal.Printf( "%s", buf );
}
/*

View file

@ -885,7 +885,7 @@ void idThread::Error( const char *fmt, ... ) const {
vsprintf( text, fmt, argptr );
va_end( argptr );
interpreter.Error( text );
interpreter.Error( "%s", text );
}
/*
@ -901,7 +901,7 @@ void idThread::Warning( const char *fmt, ... ) const {
vsprintf( text, fmt, argptr );
va_end( argptr );
interpreter.Warning( text );
interpreter.Warning( "%s", text );
}
/*

View file

@ -2523,7 +2523,7 @@ void idCommonLocal::Frame( void ) {
// the FPU stack better be empty at this point or some bad code or compiler bug left values on the stack
if ( !Sys_FPU_StackIsEmpty() ) {
Printf( Sys_FPU_GetState() );
Printf( "%s", Sys_FPU_GetState() );
FatalError( "idCommon::Frame: the FPU stack is not empty at the end of the frame\n" );
}
}

View file

@ -266,7 +266,7 @@ float SCR_DrawAsyncStats( float y ) {
idStr msg;
idAsyncNetwork::server.GetAsyncStatsAvgMsg( msg );
SCR_DrawTextRightAlign( y, msg.c_str() );
SCR_DrawTextRightAlign( y, "%s", msg.c_str() );
} else if ( idAsyncNetwork::client.IsActive() ) {

View file

@ -1028,7 +1028,7 @@ void idDeclManagerLocal::LoadManual( )
pageB = 0;
}
f->Printf( va("skin manualpage_%d_%d\n{\nmodels/weapon_map/page_%d %s\nmodels/weapon_map/page_%d %s\n}\n\n",
f->Printf( "%s", va("skin manualpage_%d_%d\n{\nmodels/weapon_map/page_%d %s\nmodels/weapon_map/page_%d %s\n}\n\n",
i, i+1,
pageA, imageNames[i].c_str(),
pageB, imageNames[i+1].c_str() ));

View file

@ -282,7 +282,7 @@ void idEditField::AutoComplete( void ) {
autoComplete = globalAutoComplete;
// and print it
idStr::snPrintf( buffer, sizeof( buffer ), autoComplete.currentMatch );
idStr::snPrintf( buffer, sizeof( buffer ), "%s", autoComplete.currentMatch );
if ( autoComplete.length > (int)strlen( buffer ) ) {
autoComplete.length = strlen( buffer );
}

View file

@ -73,40 +73,40 @@ int FS_WriteFloatString( char *buf, const char *fmt, va_list argPtr ) {
index += sprintf( buf+index, "%s", tmp.c_str() );
}
else {
index += sprintf( buf+index, format.c_str(), f );
index += sprintf( buf+index, "%s", format.c_str(), f );
}
break;
case 'd':
case 'i':
i = va_arg( argPtr, int );
index += sprintf( buf+index, format.c_str(), i );
index += sprintf( buf+index, "%s", format.c_str(), i );
break;
case 'u':
u = va_arg( argPtr, unsigned int );
index += sprintf( buf+index, format.c_str(), u );
index += sprintf( buf+index, "%s", format.c_str(), u );
break;
case 'o':
u = va_arg( argPtr, unsigned int );
index += sprintf( buf+index, format.c_str(), u );
index += sprintf( buf+index, "%s", format.c_str(), u );
break;
case 'x':
u = va_arg( argPtr, unsigned int );
index += sprintf( buf+index, format.c_str(), u );
index += sprintf( buf+index, "%s", format.c_str(), u );
break;
case 'X':
u = va_arg( argPtr, unsigned int );
index += sprintf( buf+index, format.c_str(), u );
index += sprintf( buf+index, "%s", format.c_str(), u );
break;
case 'c':
i = va_arg( argPtr, int );
index += sprintf( buf+index, format.c_str(), (char) i );
index += sprintf( buf+index, "%s", format.c_str(), (char) i );
break;
case 's':
str = va_arg( argPtr, char * );
index += sprintf( buf+index, format.c_str(), str );
index += sprintf( buf+index, "%s", format.c_str(), str );
break;
case '%':
index += sprintf( buf+index, format.c_str() );
index += sprintf( buf+index, "%s", format.c_str() );
break;
default:
common->Error( "FS_WriteFloatString: invalid format %s", format.c_str() );

View file

@ -3991,7 +3991,7 @@ void idFileSystemLocal::FindDLL( const char *name, char _dllPath[ MAX_OSPATH ],
} else {
dllPath = "";
}
idStr::snPrintf( _dllPath, MAX_OSPATH, dllPath.c_str() );
idStr::snPrintf( _dllPath, MAX_OSPATH, "%s", dllPath.c_str() );
}
/*
@ -4270,4 +4270,4 @@ idStr idFileSystemLocal::GetModDescription(idStr descPath)
}
return desc;
}
}

View file

@ -1456,7 +1456,7 @@ void idAsyncServer::ProcessAuthMessage( const idBitMsg &msg ) {
return;
}
idStr::snPrintf( challenges[ i ].guid, 12, client_guid );
idStr::snPrintf( challenges[ i ].guid, 12, "%s", client_guid );
if ( reply == AUTH_OK ) {
challenges[ i ].authState = CDK_OK;
common->Printf( "client %s %s is authed\n", Sys_NetAdrToString( client_from ), client_guid );
@ -1743,7 +1743,7 @@ void idAsyncServer::ProcessConnectMessage( const netadr_t from, const idBitMsg &
PrintOOB( from, SERVER_PRINT_MISC, msg );
// update the guid in the challenges
idStr::snPrintf( challenges[ ichallenge ].guid, sizeof( challenges[ ichallenge ].guid ), guid );
idStr::snPrintf( challenges[ ichallenge ].guid, sizeof( challenges[ ichallenge ].guid ), "%s", guid );
// once auth replied denied, stop sending further requests
if ( challenges[ ichallenge ].authReply != AUTH_DENY ) {

View file

@ -323,7 +323,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 );
}
}
@ -340,7 +340,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 );
}
}

View file

@ -76,7 +76,7 @@ int idListGUILocal::GetSelection( char *s, int size, int _sel ) const {
return -1;
}
if ( s ) {
idStr::snPrintf( s, size, m_pGUI->State().GetString( va( "%s_item_%i", m_name.c_str(), sel ), "" ) );
idStr::snPrintf( s, size, "%s", m_pGUI->State().GetString( va( "%s_item_%i", m_name.c_str(), sel ), "" ) );
}
// don't let overflow
if ( sel >= m_ids.Num() ) {