Use safe version of sprintf and strcpy

This commit is contained in:
smallmodel 2024-09-20 21:53:48 +02:00
parent a69d9d4483
commit f9d264058b
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
87 changed files with 402 additions and 395 deletions

View file

@ -5261,7 +5261,7 @@ void CG_ClientCommandDebugMessage(centity_t *cent, const char *fmt, ...)
char msg[1024];
va_start(argptr, fmt);
vsprintf(msg, fmt, argptr);
Q_vsnprintf(msg, sizeof(msg), fmt, argptr);
va_end(argptr);
if ((!cg_debugAnimWatch->integer) || ((cg_debugAnimWatch->integer - 1) == cent->currentState.number)) {
@ -5416,7 +5416,7 @@ qboolean CG_Command_ProcessFile(const char *filename, qboolean quiet, dtiki_t *c
current_tiki = NULL;
// Update the loading screen
sprintf(tempName, "m%s", filename);
Com_sprintf(tempName, sizeof(tempName), "m%s", filename);
cgi.LoadResource(tempName);
bufstart = buffer;
@ -5425,7 +5425,7 @@ qboolean CG_Command_ProcessFile(const char *filename, qboolean quiet, dtiki_t *c
Event *ev;
// grab each line as we go
strcpy(com_token, COM_ParseExt(&buffer, qtrue));
Q_strncpyz(com_token, COM_ParseExt(&buffer, qtrue), sizeof(com_token));
if (!com_token[0]) {
break;
}
@ -5433,7 +5433,7 @@ qboolean CG_Command_ProcessFile(const char *filename, qboolean quiet, dtiki_t *c
if (!Q_stricmp(com_token, "end") || !Q_stricmp(com_token, "server")) {
// skip the line
while (1) {
strcpy(com_token, COM_ParseExt(&buffer, qfalse));
Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token));
if (!com_token[0]) {
break;
}
@ -5446,7 +5446,7 @@ qboolean CG_Command_ProcessFile(const char *filename, qboolean quiet, dtiki_t *c
// get the rest of the line
while (1) {
strcpy(com_token, COM_ParseExt(&buffer, qfalse));
Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token));
if (!com_token[0]) {
break;
}
@ -5458,7 +5458,7 @@ qboolean CG_Command_ProcessFile(const char *filename, qboolean quiet, dtiki_t *c
cgi.FS_FreeFile((void *)bufstart);
// Update the loading screen
sprintf(tempName, "o%s", filename);
Com_sprintf(tempName, sizeof(tempName), "o%s", filename);
cgi.LoadResource(tempName);
return qtrue;

View file

@ -356,9 +356,9 @@ void CG_EditCHShader(void)
pShader = CG_GetShaderUnderCrosshair(qfalse, NULL);
if (pShader) {
strcpy(name, "editspecificshader ");
strcat(name, pShader->shader);
strcat(name, "\n");
Q_strncpyz(name, "editspecificshader ", sizeof(name));
Q_strcat(name, sizeof(name), pShader->shader);
Q_strcat(name, sizeof(name), "\n");
cgi.AddCommand(name);
} else {
cgi.Printf("No surface selected\n");

View file

@ -1089,7 +1089,7 @@ void CG_DrawSpectatorView_ver_15()
char buf[128];
iClientNum = cg.snap->ps.stats[STAT_INFOCLIENT];
sprintf(buf, "%s : %i", cg.clientinfo[iClientNum].name, cg.snap->ps.stats[STAT_INFOCLIENT_HEALTH]);
Com_sprintf(buf, sizeof(buf), "%s : %i", cg.clientinfo[iClientNum].name, cg.snap->ps.stats[STAT_INFOCLIENT_HEALTH]);
hShader = 0;
color[0] = 0.5;

View file

@ -369,7 +369,7 @@ void CG_ProcessConfigString(int num, qboolean modelOnly)
if (num >= CS_OBJECTIVES && num < CS_OBJECTIVES + MAX_OBJECTIVES) {
cobjective_t *objective = &cg.Objectives[num - CS_OBJECTIVES];
objective->flags = atoi(Info_ValueForKey(str, "flags"));
strcpy(objective->text, Info_ValueForKey(str, "text"));
Q_strncpyz(objective->text, Info_ValueForKey(str, "text"), sizeof(objective->text));
}
switch (num) {
@ -424,7 +424,7 @@ void CG_ProcessConfigString(int num, qboolean modelOnly)
if (len) {
qboolean streamed;
char buf[1024];
strcpy(buf, str);
Q_strncpyz(buf, str, sizeof(buf));
streamed = buf[len - 1] != '0';
buf[len - 1] = 0;
@ -826,7 +826,7 @@ void Com_Error(int level, const char *error, ...)
char text[1024];
va_start(argptr, error);
vsprintf(text, error, argptr);
Q_vsnprintf(text, sizeof(text), error, argptr);
va_end(argptr);
cgi.Error(level, "%s", text);
@ -838,7 +838,7 @@ void Com_Printf(const char *msg, ...)
char text[1024];
va_start(argptr, msg);
vsprintf(text, msg, argptr);
Q_vsnprintf(text, sizeof(text), msg, argptr);
va_end(argptr);
cgi.Printf("%s", text);

View file

@ -550,7 +550,7 @@ void CG_AnimationDebugMessage(int number, const char *fmt, ...)
char msg[1024];
va_start(argptr, fmt);
vsprintf(msg, fmt, argptr);
Q_vsnprintf(msg, sizeof(msg), fmt, argptr);
va_end(argptr);
if ((!cg_debugAnimWatch->integer) || ((cg_debugAnimWatch->integer - 1) == number)) {
@ -654,8 +654,8 @@ void CG_UpdateForceModels()
pszAlliesPartial = dm_playermodel->string;
pszAxisPartial = dm_playergermanmodel->string;
sprintf(szAlliesModel, "models/player/%s.tik", pszAlliesPartial);
sprintf(szAxisModel, "models/player/%s.tik", pszAxisPartial);
Com_sprintf(szAlliesModel, sizeof(szAlliesModel), "models/player/%s.tik", pszAlliesPartial);
Com_sprintf(szAxisModel, sizeof(szAxisModel), "models/player/%s.tik", pszAxisPartial);
hModel = cgi.R_RegisterModel(szAlliesModel);
if (!hModel) hModel = cgi.R_RegisterModel("models/player/american_army.tik");

View file

@ -1576,7 +1576,7 @@ void CG_ParseCGMessage_ver_15()
case CGM_HUDDRAW_SHADER:
iInfo = cgi.MSG_ReadByte();
strcpy(cgi.HudDrawElements[iInfo].shaderName, cgi.MSG_ReadString());
Q_strncpyz(cgi.HudDrawElements[iInfo].shaderName, cgi.MSG_ReadString(), sizeof(cgi.HudDrawElements[iInfo].shaderName));
cgi.HudDrawElements[iInfo].string[0] = 0;
cgi.HudDrawElements[iInfo].pFont = NULL;
cgi.HudDrawElements[iInfo].fontName[0] = 0;
@ -1618,12 +1618,12 @@ void CG_ParseCGMessage_ver_15()
case CGM_HUDDRAW_STRING:
iInfo = cgi.MSG_ReadByte();
cgi.HudDrawElements[iInfo].hShader = 0;
strcpy(cgi.HudDrawElements[iInfo].string, cgi.MSG_ReadString());
Q_strncpyz(cgi.HudDrawElements[iInfo].string, cgi.MSG_ReadString(), sizeof(cgi.HudDrawElements[iInfo].string));
break;
case CGM_HUDDRAW_FONT:
iInfo = cgi.MSG_ReadByte();
strcpy(cgi.HudDrawElements[iInfo].fontName, cgi.MSG_ReadString());
Q_strncpyz(cgi.HudDrawElements[iInfo].fontName, cgi.MSG_ReadString(), sizeof(cgi.HudDrawElements[iInfo].fontName));
cgi.HudDrawElements[iInfo].hShader = 0;
cgi.HudDrawElements[iInfo].shaderName[0] = 0;
// load the font
@ -1958,7 +1958,7 @@ void CG_ParseCGMessage_ver_6()
case CGM6_HUDDRAW_SHADER:
iInfo = cgi.MSG_ReadByte();
strcpy(cgi.HudDrawElements[iInfo].shaderName, cgi.MSG_ReadString());
Q_strncpyz(cgi.HudDrawElements[iInfo].shaderName, cgi.MSG_ReadString(), sizeof(cgi.HudDrawElements[iInfo].shaderName));
cgi.HudDrawElements[iInfo].string[0] = 0;
cgi.HudDrawElements[iInfo].pFont = NULL;
cgi.HudDrawElements[iInfo].fontName[0] = 0;
@ -2000,12 +2000,12 @@ void CG_ParseCGMessage_ver_6()
case CGM6_HUDDRAW_STRING:
iInfo = cgi.MSG_ReadByte();
cgi.HudDrawElements[iInfo].hShader = 0;
strcpy(cgi.HudDrawElements[iInfo].string, cgi.MSG_ReadString());
Q_strncpyz(cgi.HudDrawElements[iInfo].string, cgi.MSG_ReadString(), sizeof(cgi.HudDrawElements[iInfo].string));
break;
case CGM6_HUDDRAW_FONT:
iInfo = cgi.MSG_ReadByte();
strcpy(cgi.HudDrawElements[iInfo].fontName, cgi.MSG_ReadString());
Q_strncpyz(cgi.HudDrawElements[iInfo].fontName, cgi.MSG_ReadString(), sizeof(cgi.HudDrawElements[iInfo].fontName));
cgi.HudDrawElements[iInfo].hShader = 0;
cgi.HudDrawElements[iInfo].shaderName[0] = 0;
// load the font

View file

@ -190,8 +190,9 @@ void CG_ShowTrace(trace_t *trace, int passent, const char *reason)
assert(reason);
assert(trace);
sprintf(
Com_sprintf(
text,
sizeof(text),
"%0.2f : Pass (%d) Frac %f Hit (%d): '%s'\n",
(float)cg.time / 1000.0f,
passent,

View file

@ -58,19 +58,19 @@ void CG_PrepScoreBoardInfo()
{
switch (cgs.gametype) {
case GT_TEAM_ROUNDS:
strcpy(cg.scoresMenuName, "DM_Round_Scoreboard");
Q_strncpyz(cg.scoresMenuName, "DM_Round_Scoreboard", sizeof(cg.scoresMenuName));
break;
case GT_OBJECTIVE:
strcpy(cg.scoresMenuName, "Obj_Scoreboard");
Q_strncpyz(cg.scoresMenuName, "Obj_Scoreboard", sizeof(cg.scoresMenuName));
break;
case GT_TOW:
strcpy(cg.scoresMenuName, "Tow_Scoreboard");
Q_strncpyz(cg.scoresMenuName, "Tow_Scoreboard", sizeof(cg.scoresMenuName));
break;
case GT_LIBERATION:
strcpy(cg.scoresMenuName, "Lib_Scoreboard");
Q_strncpyz(cg.scoresMenuName, "Lib_Scoreboard", sizeof(cg.scoresMenuName));
break;
default:
strcpy(cg.scoresMenuName, "DM_Scoreboard");
Q_strncpyz(cg.scoresMenuName, "DM_Scoreboard", sizeof(cg.scoresMenuName));
break;
}
}
@ -296,14 +296,15 @@ void CG_ParseScores_ver_15()
switch (iClientTeam) {
case 1:
strcpy(szString3, cgi.LV_ConvertString("Spectators"));
Q_strncpyz(szString3, cgi.LV_ConvertString("Spectators"), sizeof(szString3));
break;
case 2:
strcpy(szString3, cgi.LV_ConvertString("Free-For-Allers"));
Q_strncpyz(szString3, cgi.LV_ConvertString("Free-For-Allers"), sizeof(szString3));
break;
case 3:
sprintf(
Com_sprintf(
szString3,
sizeof(szString3),
"%s - %d %s",
cgi.LV_ConvertString("Allies"),
atoi(cgi.Argv(2 + iCurrentEntry + iDatumCount * i)),
@ -312,8 +313,9 @@ void CG_ParseScores_ver_15()
iCurrentEntry++;
break;
case 4:
sprintf(
Com_sprintf(
szString3,
sizeof(szString3),
"%s - %d %s",
cgi.LV_ConvertString("Axis"),
atoi(cgi.Argv(2 + iCurrentEntry + iDatumCount * i)),
@ -322,7 +324,7 @@ void CG_ParseScores_ver_15()
iCurrentEntry++;
break;
default:
strcpy(szString3, cgi.LV_ConvertString("No Team"));
Q_strncpyz(szString3, cgi.LV_ConvertString("No Team"), sizeof(szString3));
break;
}
} else if (iClientNum == -2) {
@ -330,14 +332,14 @@ void CG_ParseScores_ver_15()
szString2[0] = 0;
szString3[0] = 0;
} else {
strcpy(szString2, va("%i", iClientNum));
strcpy(szString3, cg.clientinfo[iClientNum].name);
Q_strncpyz(szString2, va("%i", iClientNum), sizeof(szString2));
Q_strncpyz(szString3, cg.clientinfo[iClientNum].name, sizeof(szString3));
}
strcpy(szString4, cgi.Argv(2 + iCurrentEntry + iDatumCount * i));
strcpy(szString5, cgi.Argv(3 + iCurrentEntry + iDatumCount * i));
strcpy(szString6, cgi.Argv(4 + iCurrentEntry + iDatumCount * i));
strcpy(szString7, cgi.Argv(5 + iCurrentEntry + iDatumCount * i));
Q_strncpyz(szString4, cgi.Argv(2 + iCurrentEntry + iDatumCount * i), sizeof(szString4));
Q_strncpyz(szString5, cgi.Argv(3 + iCurrentEntry + iDatumCount * i), sizeof(szString5));
Q_strncpyz(szString6, cgi.Argv(4 + iCurrentEntry + iDatumCount * i), sizeof(szString6));
Q_strncpyz(szString7, cgi.Argv(5 + iCurrentEntry + iDatumCount * i), sizeof(szString7));
if (cgs.gametype >= GT_TEAM_ROUNDS && iClientNum == -1
&& (iClientTeam == TEAM_ALLIES || iClientTeam == TEAM_AXIS)) {
@ -370,19 +372,19 @@ void CG_ParseScores_ver_15()
} else {
iClientNum = atoi(cgi.Argv(iCurrentEntry + iDatumCount * i));
if (iClientNum >= 0) {
strcpy(szString2, va("%i", iClientNum));
strcpy(szString3, cg.clientinfo[iClientNum].name);
strcpy(szString4, cgi.Argv(1 + iCurrentEntry + iDatumCount * i));
strcpy(szString5, cgi.Argv(2 + iCurrentEntry + iDatumCount * i));
strcpy(szString6, cgi.Argv(3 + iCurrentEntry + iDatumCount * i));
strcpy(szString7, cgi.Argv(4 + iCurrentEntry + iDatumCount * i));
Q_strncpyz(szString2, va("%i", iClientNum), sizeof(szString2));
Q_strncpyz(szString3, cg.clientinfo[iClientNum].name, sizeof(szString3));
Q_strncpyz(szString4, cgi.Argv(1 + iCurrentEntry + iDatumCount * i), sizeof(szString4));
Q_strncpyz(szString5, cgi.Argv(2 + iCurrentEntry + iDatumCount * i), sizeof(szString5));
Q_strncpyz(szString6, cgi.Argv(3 + iCurrentEntry + iDatumCount * i), sizeof(szString6));
Q_strncpyz(szString7, cgi.Argv(4 + iCurrentEntry + iDatumCount * i), sizeof(szString7));
} else {
szString2[0] = 0;
if (iClientNum == -3) {
strcpy(szString2, cgi.LV_ConvertString("Players"));
Q_strncpyz(szString2, cgi.LV_ConvertString("Players"), sizeof(szString2));
bIsHeader = qtrue;
} else if (iClientNum == -2) {
strcpy(szString2, cgi.LV_ConvertString("Spectators"));
Q_strncpyz(szString2, cgi.LV_ConvertString("Spectators"), sizeof(szString3));
bIsHeader = qtrue;
} else {
// unknown
@ -535,32 +537,32 @@ void CG_ParseScores_ver_6()
switch (iClientTeam) {
case 1:
strcpy(szString2, cgi.LV_ConvertString("Spectators"));
Q_strncpyz(szString2, cgi.LV_ConvertString("Spectators"), sizeof(szString2));
break;
case 2:
strcpy(szString2, cgi.LV_ConvertString("Free-For-Allers"));
Q_strncpyz(szString2, cgi.LV_ConvertString("Free-For-Allers"), sizeof(szString2));
break;
case 3:
strcpy(szString2, cgi.LV_ConvertString("Allies"));
Q_strncpyz(szString2, cgi.LV_ConvertString("Allies"), sizeof(szString2));
break;
case 4:
strcpy(szString2, cgi.LV_ConvertString("Axis"));
Q_strncpyz(szString2, cgi.LV_ConvertString("Axis"), sizeof(szString2));
break;
default:
strcpy(szString2, cgi.LV_ConvertString("No Team"));
Q_strncpyz(szString2, cgi.LV_ConvertString("No Team"), sizeof(szString2));
break;
}
} else if (iClientNum == -2) {
// spectating
szString2[0] = 0;
} else {
strcpy(szString2, cg.clientinfo[iClientNum].name);
Q_strncpyz(szString2, cg.clientinfo[iClientNum].name, sizeof(szString2));
}
strcpy(szString3, cgi.Argv(2 + iCurrentEntry + iDatumCount * i));
strcpy(szString4, cgi.Argv(3 + iCurrentEntry + iDatumCount * i));
strcpy(szString5, cgi.Argv(4 + iCurrentEntry + iDatumCount * i));
strcpy(szString6, cgi.Argv(5 + iCurrentEntry + iDatumCount * i));
Q_strncpyz(szString3, cgi.Argv(2 + iCurrentEntry + iDatumCount * i), sizeof(szString3));
Q_strncpyz(szString4, cgi.Argv(3 + iCurrentEntry + iDatumCount * i), sizeof(szString4));
Q_strncpyz(szString5, cgi.Argv(4 + iCurrentEntry + iDatumCount * i), sizeof(szString5));
Q_strncpyz(szString6, cgi.Argv(5 + iCurrentEntry + iDatumCount * i), sizeof(szString6));
if (iClientNum == cg.snap->ps.clientNum) {
pItemTextColor = vThisClientTextColor;
@ -587,17 +589,17 @@ void CG_ParseScores_ver_6()
} else {
iClientNum = atoi(cgi.Argv(iCurrentEntry + iDatumCount * i));
if (iClientNum >= 0) {
strcpy(szString2, cg.clientinfo[iClientNum].name);
strcpy(szString3, cgi.Argv(1 + iCurrentEntry + iDatumCount * i));
strcpy(szString4, cgi.Argv(2 + iCurrentEntry + iDatumCount * i));
strcpy(szString5, cgi.Argv(3 + iCurrentEntry + iDatumCount * i));
strcpy(szString6, cgi.Argv(4 + iCurrentEntry + iDatumCount * i));
Q_strncpyz(szString2, cg.clientinfo[iClientNum].name, sizeof(szString2));
Q_strncpyz(szString3, cgi.Argv(1 + iCurrentEntry + iDatumCount * i), sizeof(szString3));
Q_strncpyz(szString4, cgi.Argv(2 + iCurrentEntry + iDatumCount * i), sizeof(szString4));
Q_strncpyz(szString5, cgi.Argv(3 + iCurrentEntry + iDatumCount * i), sizeof(szString5));
Q_strncpyz(szString6, cgi.Argv(4 + iCurrentEntry + iDatumCount * i), sizeof(szString6));
} else {
if (iClientNum == -3) {
strcpy(szString2, cgi.LV_ConvertString("Players"));
Q_strncpyz(szString2, cgi.LV_ConvertString("Players"), sizeof(szString2));
bIsHeader = qtrue;
} else if (iClientNum == -2) {
strcpy(szString2, cgi.LV_ConvertString("Spectators"));
Q_strncpyz(szString2, cgi.LV_ConvertString("Spectators"), sizeof(szString2));
bIsHeader = qtrue;
} else {
// unknown

View file

@ -186,7 +186,7 @@ void CG_ParseServerinfo(void)
if (spawnpos) {
Q_strncpyz(map, mapname, spawnpos - mapname + 1);
} else {
strcpy(map, mapname);
Q_strncpyz(map, mapname, sizeof(map));
}
Com_sprintf(cgs.mapname, sizeof(cgs.mapname), "maps/%s.bsp", map);

View file

@ -351,7 +351,7 @@ void CG_ViewModelAnimation(refEntity_t *pModel)
} else {
iAnimPrefixIndex = CG_GetVMAnimPrefixIndex();
cgi.anim->g_iLastEquippedWeaponStat = cg.snap->ps.stats[STAT_EQUIPPED_WEAPON];
strcpy(cgi.anim->g_szLastActiveItem, CG_ConfigString(CS_WEAPONS + cg.snap->ps.activeItems[1]));
Q_strncpyz(cgi.anim->g_szLastActiveItem, CG_ConfigString(CS_WEAPONS + cg.snap->ps.activeItems[1]), sizeof(cgi.anim->g_szLastActiveItem));
cgi.anim->g_iLastAnimPrefixIndex = iAnimPrefixIndex;
bAnimChanged = qtrue;
@ -359,7 +359,7 @@ void CG_ViewModelAnimation(refEntity_t *pModel)
}
if (cgi.anim->g_iLastVMAnim == -1) {
sprintf(szAnimName, "%s_idle", AnimPrefixList[iAnimPrefixIndex]);
Com_sprintf(szAnimName, sizeof(szAnimName), "%s_idle", AnimPrefixList[iAnimPrefixIndex]);
cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index = cgi.Anim_NumForName(pTiki, szAnimName);
if (cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index == -1) {
@ -428,7 +428,7 @@ void CG_ViewModelAnimation(refEntity_t *pModel)
break;
}
sprintf(szAnimName, "%s_%s", AnimPrefixList[iAnimPrefixIndex], pszAnimSuffix);
Com_sprintf(szAnimName, sizeof(szAnimName), "%s_%s", AnimPrefixList[iAnimPrefixIndex], pszAnimSuffix);
if (!bWeaponChanged) {
fCrossblendTime =
cgi.Anim_CrossblendTime(pTiki, cgi.anim->g_VMFrameInfo[cgi.anim->g_iCurrentVMAnimSlot].index);

View file

@ -1480,7 +1480,7 @@ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBi
cin.currentHandle = currentHandle;
strcpy(cinTable[currentHandle].fileName, name);
Q_strncpyz(cinTable[currentHandle].fileName, name, sizeof(cinTable[currentHandle].fileName));
cinTable[currentHandle].ROQSize = 0;
cinTable[currentHandle].ROQSize = FS_FOpenFileRead (cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue, qtrue);
@ -1655,7 +1655,7 @@ static unsigned short CL_PlayRoQ(const char* name, const char* arg, const char*
cin.currentHandle = currentHandle;
strcpy(cinTable[currentHandle].fileName, name);
Q_strncpyz(cinTable[currentHandle].fileName, name, sizeof(cinTable[currentHandle].fileName));
cinTable[currentHandle].ROQSize = 0;
cinTable[currentHandle].ROQSize = FS_FOpenFileRead (cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue, qtrue);

View file

@ -148,7 +148,7 @@ void CL_Draw3DModel(
hModel[iCurrNum] = model;
iIndex[iCurrNum] = -1;
strcpy(szAnimName[iCurrNum], anim);
Q_strncpyz(szAnimName[iCurrNum], anim, sizeof(szAnimName[iCurrNum]));
} else {
iCurrNum = i;
@ -164,7 +164,7 @@ void CL_Draw3DModel(
}
} else {
iIndex[iCurrNum] = -1;
strcpy(szAnimName[iCurrNum], anim);
Q_strncpyz(szAnimName[iCurrNum], anim, sizeof(szAnimName[iCurrNum]));
}
}

View file

@ -1172,12 +1172,12 @@ void CL_Setenv_f( void ) {
char buffer[1024];
int i;
strcpy( buffer, Cmd_Argv(1) );
strcat( buffer, "=" );
Q_strncpyz( buffer, Cmd_Argv(1), sizeof( buffer ) );
Q_strcat( buffer, sizeof( buffer ), "=" );
for ( i = 2; i < argc; i++ ) {
strcat( buffer, Cmd_Argv( i ) );
strcat( buffer, " " );
Q_strcat( buffer, sizeof( buffer ), Cmd_Argv( i ) );
Q_strcat( buffer, sizeof( buffer ), " " );
}
putenv( buffer );
@ -2000,7 +2000,7 @@ wombat: sending conect here: an example connect string from MOHAA looks like thi
Info_SetValueForKey(info, "clientType", "Breakthrough");
}
strcpy(data, "connect ");
Q_strncpyz(data, "connect ", sizeof(data));
// TTimo adding " " around the userinfo string to avoid truncated userinfo on the server
// (Com_TokenizeString tokenizes around spaces)
data[8] = '"';
@ -3126,7 +3126,7 @@ void CL_VidMode_f( void ) {
mode = atoi( Cmd_Argv( 1 ) );
if( CL_SetVidMode( mode ) ) {
sprintf( text, "%d", mode );
Com_sprintf( text, sizeof( text ), "%d", mode );
Cvar_Set( "r_mode", text );
}
}
@ -3145,10 +3145,10 @@ void CL_TikiInfoCommand_f( void ) {
name = Cmd_Argv( 1 );
if( strchr( name, '/' ) ) {
strcpy( modelname, name );
Q_strncpyz( modelname, name, sizeof( modelname ) );
} else {
strcpy( modelname, "models/" );
strcat( modelname, name );
Q_strncpyz( modelname, "models/", sizeof( modelname ) );
Q_strcat( modelname, sizeof( modelname ), name );
}
COM_DefaultExtension( modelname, sizeof( modelname ), ".tik" );
@ -3997,7 +3997,7 @@ void CL_GlobalServers_f( void ) {
int numAddress = 0;
for ( i = 1; i <= MAX_MASTER_SERVERS; i++ ) {
sprintf(command, "sv_master%d", i);
Com_sprintf(command, sizeof(command), "sv_master%d", i);
masteraddress = Cvar_VariableString(command);
if(!*masteraddress)
@ -4015,7 +4015,7 @@ void CL_GlobalServers_f( void ) {
return;
}
sprintf(command, "sv_master%d", masterNum);
Com_sprintf(command, sizeof(command), "sv_master%d", masterNum);
masteraddress = Cvar_VariableString(command);
if(!*masteraddress)
@ -4344,10 +4344,10 @@ void CL_Dialog_f( void ) {
return;
}
strcpy( title, Cmd_Argv( 1 ) );
strcpy( cvar, Cmd_Argv( 2 ) );
strcpy( command, Cmd_Argv( 3 ) );
strcpy( cancelCommand, Cmd_Argv( 4 ) );
Q_strncpyz( title, Cmd_Argv( 1 ), sizeof( title ) );
Q_strncpyz( cvar, Cmd_Argv( 2 ), sizeof( cvar ) );
Q_strncpyz( command, Cmd_Argv( 3 ), sizeof( command ) );
Q_strncpyz( cancelCommand, Cmd_Argv( 4 ), sizeof( cancelCommand ) );
if( Cmd_Argc() > 5 ) {
width = atoi( Cmd_Argv( 5 ) );
@ -4361,17 +4361,17 @@ void CL_Dialog_f( void ) {
}
if( Cmd_Argc() > 7 ) {
strcpy( shader, Cmd_Argv( 7 ) );
Q_strncpyz( shader, Cmd_Argv( 7 ), sizeof( shader ) );
} else {
shader[ 0 ] = 0;
}
if( Cmd_Argc() > 8 ) {
strcpy( okshader, Cmd_Argv( 8 ) );
Q_strncpyz( okshader, Cmd_Argv( 8 ), sizeof(okshader) );
} else {
okshader[ 0 ] = 0;
}
if( Cmd_Argc() > 9 ) {
strcpy( cancelshader, Cmd_Argv( 9 ) );
Q_strncpyz( cancelshader, Cmd_Argv( 9 ), sizeof(cancelshader) );
} else {
cancelshader[ 0 ] = 0;
}
@ -4615,7 +4615,7 @@ qboolean CL_CDKeyValidate( const char *key, const char *checksum ) {
}
}
sprintf(chs, "%02x", sum);
Com_sprintf(chs, sizeof(chs), "%02x", sum);
if (checksum && !Q_stricmp(chs, checksum)) {
return qtrue;

View file

@ -343,7 +343,7 @@ void SCR_DrawDemoRecording( void ) {
}
pos = FS_FTell( clc.demofile );
sprintf( string, "RECORDING %s: %ik", clc.demoName, pos / 1024 );
Com_sprintf( string, sizeof( string ), "RECORDING %s: %ik", clc.demoName, pos / 1024 );
SCR_DrawStringExt( 320 - strlen( string ) * 4, 20, 8, string, g_color_table[7], qtrue, qfalse );
}

View file

@ -5826,12 +5826,12 @@ void UI_EndLoad(void)
}
file = FS_FOpenFileWrite(loadName);
sprintf(buf, "%d\n%d %d\n", 3, loadNumber, size);
Com_sprintf(buf, sizeof(buf), "%d\n%d %d\n", 3, loadNumber, size);
FS_Write(buf, strlen(buf), file);
for (i = 0; i < loadNumber; i++) {
sprintf(buf, "%s\n%d\n", base[i]->name, base[i]->loadCount);
Com_sprintf(buf, sizeof(buf), "%s\n%d\n", base[i]->name, base[i]->loadCount);
FS_Write(buf, strlen(buf), file);
}

View file

@ -76,7 +76,7 @@ void UIMapRotationListBox::PopulateRotationList()
maplistVar = Cvar_Get("ui_maplist_ffa", "", 0);
}
strcpy(mapBuffer, maplistVar->string);
Q_strncpyz(mapBuffer, maplistVar->string, sizeof(mapBuffer));
for (token = strtok(mapBuffer, " /"); token; token = strtok(NULL, " /")) {
if (!Q_stricmp(token, "dm")) {
@ -143,7 +143,7 @@ void UIMapListBox::PopulateMapList()
bool bHasTOW = false;
bool bHasLib = false;
strcpy(mapName, filename);
Q_strncpyz(mapName, filename, sizeof(mapName));
mapName[strlen(mapName) - 4] = 0;
if (!COM_IsMapValid(mapName)) {
@ -151,7 +151,7 @@ void UIMapListBox::PopulateMapList()
}
if (bTugOfWar || bLiberation) {
strcpy(tokenized, mapName);
Q_strncpyz(tokenized, mapName, sizeof(tokenized));
for (token = strtok(tokenized, "_"); token; token = strtok(NULL, "_")) {
if (bLiberation) {
@ -181,7 +181,7 @@ void UIMapListBox::PopulateMapList()
}
}
} else if (bObjective) {
strcpy(tokenized, mapName);
Q_strncpyz(tokenized, mapName, sizeof(tokenized));
for (token = strtok(tokenized, "_"); token; token = strtok(NULL, "_")) {
if (!Q_stricmp(token, "obj")) {
@ -209,9 +209,9 @@ void UIMapListBox::PopulateMapList()
char mapName[256];
char tokenized[256];
strcpy(mapName, filename);
Q_strncpyz(mapName, filename, sizeof(mapName));
mapName[strlen(mapName) - 4] = 0;
strcpy(tokenized, mapName);
Q_strncpyz(tokenized, mapName, sizeof(tokenized));
token = strtok(tokenized, "_");
if (!Q_stricmp(token, "obj") || !Q_stricmp(mapName, "mp_ship_lib")) {
@ -237,7 +237,7 @@ void UIMapListBox::PopulateMapList()
const char *filename = filenames[i];
char mapName[256];
strcpy(mapName, filename);
Q_strncpyz(mapName, filename, sizeof(mapName));
mapName[strlen(mapName) - 4] = 0;
if (!COM_IsMapValid(mapName)) {
@ -356,7 +356,7 @@ void UIRotationApplyButton::Released(Event *ev)
char map[256];
bool bHasTOW = false, bHasObj = false, bHasLib = false, bHasShip = false;
strcpy(map, text);
Q_strncpyz(map, text, sizeof(map));
for (token = strtok(map, "_"); token; token = strtok(NULL, "_")) {
if (!Q_stricmp(token, "TOW")) {
bHasTOW = true;

View file

@ -642,9 +642,9 @@ void UIFAKKServerList::RefreshLANServerList( Event *ev )
static void AddFilter(char* filter, const char* value) {
if (*filter) {
strcat(filter, va(" and %s", value));
Q_strcat(filter, sizeof(filter), va(" and %s", value));
} else {
strcpy(filter, value);
Q_strncpyz(filter, value, sizeof(filter));
}
}

View file

@ -86,27 +86,27 @@ void View3D::PrintSound(int channel, const char *name, float vol, int rvol, floa
xStep = height;
x = 0;
sprintf(buf, "%d", channel);
Com_sprintf(buf, sizeof(buf), "%d", channel);
m_font->Print(x, height * line + m_frame.pos.y, buf, -1, false);
x += xStep + xStep;
sprintf(buf, "%s", name);
Com_sprintf(buf, sizeof(buf), "%s", name);
m_font->Print(x, height * line + m_frame.pos.y, buf, -1, false);
x += xStep * 30.0;
sprintf(buf, "vol:%.2f", vol);
Com_sprintf(buf, sizeof(buf), "vol:%.2f", vol);
m_font->Print(x, height * line + m_frame.pos.y, buf, -1, false);
x += xStep * 8;
sprintf(buf, "rvol:%.2f", (float)(rvol / 128.f));
Com_sprintf(buf, sizeof(buf), "rvol:%.2f", (float)(rvol / 128.f));
m_font->Print(x, height * line + m_frame.pos.y, buf, -1, false);
x += xStep * 5;
sprintf(buf, "pit:%.2f", pitch);
Com_sprintf(buf, sizeof(buf), "pit:%.2f", pitch);
m_font->Print(x, height * line + m_frame.pos.y, buf, -1, false);
x += xStep * 5;
sprintf(buf, "base:%d", (int)base);
Com_sprintf(buf, sizeof(buf), "base:%d", (int)base);
m_font->Print(x, height * line + m_frame.pos.y, buf, -1, false);
line++;
@ -228,7 +228,7 @@ void View3D::InitSubtitle(void)
for (int i = 0; i < 4; i++) {
subs[i] = Cvar_Get(va("subtitle%d", i), "", 0);
teams[i] = Cvar_Get(va("subteam%d", i), "0", 0);
strcpy(oldStrings[i], subs[i]->string);
Q_strncpyz(oldStrings[i], subs[i]->string, sizeof(oldStrings[i]));
fadeTime[i] = 4000.0;
subLife[i] = 4000.0;
}
@ -300,7 +300,7 @@ void View3D::DrawSubtitleOverlay(void)
int blockcount;
c = buf;
strcpy(buf, subs[i]->string);
Q_strncpyz(buf, subs[i]->string, sizeof(buf));
total = 0;
end = NULL;
@ -420,7 +420,7 @@ void View3D::DrawFPS(void)
);
}
sprintf(string, "FPS %4.1f", currentfps);
Com_sprintf(string, sizeof(string), "FPS %4.1f", currentfps);
if (currentfps > 23.94) {
if (cl_greenfps->integer) {
m_font->setColor(UGreen);
@ -449,7 +449,7 @@ void View3D::DrawFPS(void)
m_font->setColor(UWhite);
}
sprintf(string, "wt%5d wv%5d cl%d", cls.world_tris, cls.world_verts, cls.character_lights);
Com_sprintf(string, sizeof(string), "wt%5d wv%5d cl%d", cls.world_tris, cls.world_verts, cls.character_lights);
m_font->Print(
m_font->getHeight(qfalse) * 10.0,
@ -459,7 +459,7 @@ void View3D::DrawFPS(void)
qfalse
);
sprintf(string, "t%5d v%5d Mtex%5.2f", cls.total_tris, cls.total_verts, (float)cls.total_texels * 0.00000095367432);
Com_sprintf(string, sizeof(string), "t%5d v%5d Mtex%5.2f", cls.total_tris, cls.total_verts, (float)cls.total_texels * 0.00000095367432);
m_font->Print(
m_font->getHeight(qfalse) * 10.0,

View file

@ -161,12 +161,12 @@ void S_Base_SoundList( void ) {
char type[4][16];
char mem[2][16];
strcpy(type[0], "16bit");
strcpy(type[1], "adpcm");
strcpy(type[2], "daub4");
strcpy(type[3], "mulaw");
strcpy(mem[0], "paged out");
strcpy(mem[1], "resident ");
Q_strncpyz(type[0], "16bit", sizeof(type[0]));
Q_strncpyz(type[1], "adpcm", sizeof(type[1]));
Q_strncpyz(type[2], "daub4", sizeof(type[2]));
Q_strncpyz(type[3], "mulaw", sizeof(type[3]));
Q_strncpyz(mem[0], "paged out", sizeof(mem[0]));
Q_strncpyz(mem[1], "resident ", sizeof(mem[1]));
total = 0;
for (sfx=s_knownSfx, i=0 ; i<s_numSfx ; i++, sfx++) {
size = sfx->soundLength;
@ -303,7 +303,7 @@ static sfx_t *S_FindName( const char *name ) {
sfx = &s_knownSfx[i];
Com_Memset (sfx, 0, sizeof(*sfx));
strcpy (sfx->soundName, name);
Q_strncpyz (sfx->soundName, name, sizeof(sfx->soundName));
sfx->next = sfxHash[hash];
sfxHash[hash] = sfx;

View file

@ -522,7 +522,7 @@ qboolean S_LoadSound(const char *fileName, sfx_t *sfx, int streamed, qboolean fo
sfx->data = NULL;
}
sprintf(tempName, "k%s", fileName);
Com_sprintf(tempName, sizeof(tempName), "k%s", fileName);
UI_LoadResource(tempName);
if (strstr(fileName, "sound/null.wav")) {

View file

@ -233,7 +233,7 @@ static sfxHandle_t S_AL_BufferFind(const char *filename)
ptr = &knownSfx[sfx];
memset(ptr, 0, sizeof(*ptr));
ptr->masterLoopSrc = -1;
strcpy(ptr->filename, filename);
Q_strncpyz(ptr->filename, filename, sizeof(ptr->filename));
}
// Return the handle

View file

@ -3357,7 +3357,7 @@ qboolean MUSIC_LoadSoundtrackFile(const char *filename)
load_path[0] = 0;
while (1) {
strcpy(com_token, COM_GetToken(&buffer, true));
Q_strncpyz(com_token, COM_GetToken(&buffer, true), sizeof(com_token));
if (!com_token[0]) {
break;
}
@ -3368,10 +3368,10 @@ qboolean MUSIC_LoadSoundtrackFile(const char *filename)
}
numargs = 1;
strcpy(args[0], com_token);
Q_strncpyz(args[0], com_token, sizeof(args[0]));
while (1) {
strcpy(com_token, COM_GetToken(&buffer, false));
Q_strncpyz(com_token, COM_GetToken(&buffer, false), sizeof(com_token));
if (!com_token[0]) {
break;
}
@ -3381,14 +3381,14 @@ qboolean MUSIC_LoadSoundtrackFile(const char *filename)
com_token[MAX_RES_NAME - 1] = 0;
}
strcpy(args[numargs], com_token);
Q_strncpyz(args[numargs], com_token, sizeof(args[numargs]));
numargs++;
}
if (!Q_stricmp(args[0], "path")) {
strcpy(load_path, args[1]);
Q_strncpyz(load_path, args[1], sizeof(load_path));
if (load_path[strlen(load_path) - 1] != '/' && load_path[strlen(load_path) - 1] != '\\') {
strcat(load_path, "/");
Q_strcat(load_path, sizeof(load_path), "/");
}
} else if (args[0][0] == '!') {
for (i = 0; i < music_numsongs; i++) {
@ -3421,14 +3421,14 @@ qboolean MUSIC_LoadSoundtrackFile(const char *filename)
}
} else {
if (numargs > 1) {
strcpy(alias, args[0]);
strcpy(file, load_path);
strcat(file, args[1]);
Q_strncpyz(alias, args[0], sizeof(alias));
Q_strncpyz(file, load_path, sizeof(file));
Q_strcat(file, sizeof(file), args[1]);
} else {
strcpy(file, load_path);
strcat(file, args[1]);
Q_strncpyz(file, load_path, sizeof(file));
Q_strcat(file, sizeof(file), args[1]);
strncpy(alias, args[0], strlen(args[0]) - 4);
Q_strncpyz(alias, args[0], strlen(args[0]) - 4);
file[strlen(args[0]) + MAX_RES_NAME * 2 - 4] = 0;
}
@ -3438,8 +3438,8 @@ qboolean MUSIC_LoadSoundtrackFile(const char *filename)
}
psong = &music_songs[music_numsongs];
strcpy(psong->alias, alias);
strcpy(psong->path, file);
Q_strncpyz(psong->alias, alias, sizeof(psong->alias));
Q_strncpyz(psong->path, file, sizeof(psong->path));
music_songs[music_numsongs].fadetime = 1.0;
music_songs[music_numsongs].volume = 1.0;
music_songs[music_numsongs].flags = 0;

View file

@ -12282,8 +12282,9 @@ const char *Actor::DumpCallTrace(const char *pszFmt, ...) const
vPlayer = p->origin;
}
i1 = sprintf(
i1 = Com_sprintf(
szTemp,
sizeof(szTemp),
"map = %s\n"
"time = %i (%i:%02i)\n"
"entnum = %i, targetname = '%s'\n"
@ -12318,7 +12319,7 @@ const char *Actor::DumpCallTrace(const char *pszFmt, ...) const
if (pszFmt) {
va_list args2;
va_copy(args2, args);
i2 = i1 + vsprintf(&szTemp[i1], pszFmt, args);
i2 = i1 + Q_vsnprintf(szTemp + i1, sizeof(szTemp) - i1, pszFmt, args);
}
va_end(args);
@ -12329,8 +12330,9 @@ const char *Actor::DumpCallTrace(const char *pszFmt, ...) const
t = time(0);
ptm = localtime(&t);
sprintf(
Com_sprintf(
szFile,
sizeof(szFile),
"main\\ai_trace_%s_%i_%i_%02i%02i.log",
sv_mapname->string,
ptm->tm_mon + 1,

View file

@ -120,7 +120,7 @@ void Actor::Think_DisguiseOfficer(void)
{
Com_Printf("Actor::Think_DisguiseOfficer: invalid think state %i\n", m_State);
char assertStr[16317] = {0};
strcpy(assertStr, "\"invalid think state\"\n\tMessage: ");
Q_strncpyz(assertStr, "\"invalid think state\"\n\tMessage: ", sizeof(assertStr));
Q_strcat(assertStr, sizeof(assertStr), DumpCallTrace("thinkstate = %i", m_State));
assert(!assertStr);
}

View file

@ -124,7 +124,7 @@ void Actor::Think_DisguiseRover(void)
{
Com_Printf("Actor::Think_DisguiseOfficer: invalid think state %i\n", m_State);
char assertStr[16317] = {0};
strcpy(assertStr, "\"invalid think state\"\n\tMessage: ");
Q_strncpyz(assertStr, "\"invalid think state\"\n\tMessage: ", sizeof(assertStr));
Q_strcat(assertStr, sizeof(assertStr), DumpCallTrace("thinkstate = %i", m_State));
assert(!assertStr);
}

View file

@ -474,7 +474,7 @@ void Actor::FinishedAnimation_Grenade(void)
break;
default:
char assertStr[16317] = {0};
strcpy(assertStr, "\"invalid grenade state in FinishedAnimation()\"\n\tMessage: ");
Q_strncpyz(assertStr, "\"invalid grenade state in FinishedAnimation()\"\n\tMessage: ", sizeof(assertStr));
Q_strcat(assertStr, sizeof(assertStr), DumpCallTrace("state = %i", m_eGrenadeState));
assert(!assertStr);
break;

View file

@ -121,7 +121,7 @@ void Actor::Think_Weaponless(void)
} else {
Com_Printf("Think_Weaponless: invalid think state %i\n", m_State);
char assertStr[16317] = {0};
strcpy(assertStr, "\"invalid think state\"\n\tMessage: ");
Q_strncpyz(assertStr, "\"invalid think state\"\n\tMessage: ", sizeof(assertStr));
Q_strcat(assertStr, sizeof(assertStr), DumpCallTrace("thinkstate = %i", m_State));
assert(!assertStr);
}

View file

@ -315,8 +315,8 @@ void Animate::NewAnim(int animnum, int slot, float weight)
const tiki_singlecmd_t& single_cmd = cmds.cmds[ii];
int eventNum;
strcpy(cmdName, "_client_");
strcpy(cmdName + 8, single_cmd.args[0]);
Q_strncpyz(cmdName, "_client_", longest + 8 + 1);
Q_strncpyz(cmdName + 8, single_cmd.args[0], longest + 1);
eventNum = Event::FindEventNum(cmdName);
@ -386,8 +386,8 @@ void Animate::NewAnim(int animnum, int slot, float weight)
const tiki_singlecmd_t& single_cmd = cmds.cmds[ii];
int eventNum;
strcpy(cmdName, "_client_");
strcpy(cmdName + 8, single_cmd.args[0]);
Q_strncpyz(cmdName, "_client_", longestAllFrames + 8 + 1);
Q_strncpyz(cmdName + 8, single_cmd.args[0], longestAllFrames + 1);
eventNum = Event::FindEventNum(cmdName);
@ -554,8 +554,8 @@ void Animate::DoExitCommands(int slot)
const tiki_singlecmd_t& single_cmd = cmds.cmds[ii];
int eventNum;
strcpy(cmdName, "_client_");
strcpy(cmdName + 8, single_cmd.args[0]);
Q_strncpyz(cmdName, "_client_", longest + 8 + 1);
Q_strncpyz(cmdName + 8, single_cmd.args[0], longest + 1);
eventNum = Event::FindEventNum(cmdName);

View file

@ -310,7 +310,7 @@ void Archiver::FileError(const char *fmt, ...)
char text[1024];
va_start(argptr, fmt);
vsprintf(text, fmt, argptr);
Q_vsnprintf(text, sizeof(text), fmt, argptr);
va_end(argptr);
fileerror = true;

View file

@ -1411,11 +1411,11 @@ void Camera::SetAutoStateEvent(Event *ev)
char com_token[MAX_QPATH];
char com_buffer[MAX_STRING_CHARS];
strcpy(com_buffer, ev->GetString(i));
Q_strncpyz(com_buffer, ev->GetString(i), sizeof(com_buffer));
buffer = com_buffer;
// get the rest of the line
while (1) {
strcpy(com_token, COM_ParseExt(&buffer, qfalse));
Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token));
if (!com_token[0]) {
break;
}

View file

@ -373,7 +373,7 @@ void State::ParseAndProcessCommand(str command, Entity *target)
script.SkipToEOL();
break;
}
strcpy(args[argc], script.GetToken(false));
Q_strncpyz(args[argc], script.GetToken(false), sizeof(args[argc]));
argv[argc] = args[argc];
argc++;
}

View file

@ -433,7 +433,7 @@ void G_DrawDebugNumber(Vector org, float number, float scale, float r, float g,
left *= scale;
if (precision > 0) {
sprintf(format, "%%.%df", precision);
Com_sprintf(format, sizeof(format), "%%.%df", precision);
text = va(format, number);
} else {
text = va("%d", (int)number);
@ -761,7 +761,7 @@ void G_DebugString(Vector pos, float scale, float r, float g, float b, const cha
(*gi.numDebugStrings)++;
va_start(va, pszText);
vsprintf(szTemp, pszText, va);
Q_vsnprintf(szTemp, sizeof(szTemp), pszText, va);
va_end(va);
VectorCopy(pos, string->pos);

View file

@ -1798,7 +1798,7 @@ void DM_Manager::InsertEntry(const char *entry)
size_t len = strlen(entry);
if (scoreLength + len < MAX_STRING_CHARS) {
strcpy(scoreString + scoreLength, entry);
Q_strncpyz(scoreString + scoreLength, entry, sizeof(scoreString) - scoreLength);
scoreLength += len;
scoreEntries++;
@ -1810,7 +1810,7 @@ void DM_Manager::InsertEntryNoCount(const char *entry)
size_t len = strlen(entry);
if (scoreLength + len < MAX_STRING_CHARS) {
strcpy(scoreString + scoreLength, entry);
Q_strncpyz(scoreString + scoreLength, entry, sizeof(scoreString) - scoreLength);
scoreLength += len;
}

View file

@ -1220,13 +1220,13 @@ void Door::ShowInfo(float fDot, float fDist)
return;
}
i = sprintf(szText, "%i:%i", entnum, radnum);
i = Com_sprintf(szText, sizeof(szText), "%i:%i", entnum, radnum);
if (TargetName().c_str() && TargetName()[0]) {
i = sprintf(szText + i, ":%s", TargetName().c_str());
i = Com_sprintf(szText + i, sizeof(szText) - i, ":%s", TargetName().c_str());
}
if (health != 0) {
i = sprintf(szText + i, ":%.1f", health);
i = Com_sprintf(szText + i, sizeof(szText) - i, ":%.1f", health);
}
G_DebugString(origin + Vector(0, 0, (mins.z + maxs.z) * 0.5f), 1, 1, 1, 1, szText);

View file

@ -5624,13 +5624,13 @@ void Entity::ShowInfo(float fDot, float fDist)
int i;
char szText[512];
if (fDot > 0.94999999 && fDist < 1024.0 && fDist > 64.0) {
i = sprintf(szText, "%i:%i", entnum, radnum);
i = Com_sprintf(szText, sizeof(szText), "%i:%i", entnum, radnum);
if (targetname.length()) {
i = sprintf(&szText[i], ":%s", targetname.c_str());
i = Com_sprintf(szText + i, sizeof(szText) - i, ":%s", targetname.c_str());
}
if (health != 0) {
sprintf(&szText[i], ":%.1f", health);
Com_sprintf(szText + i, sizeof(szText) - i, ":%.1f", health);
}
G_DebugString(Vector(origin.x + 0, origin.y + 0, origin.z + maxs.z + 65), 1.0, 1.0, 1.0, 1.0, szText);

View file

@ -487,7 +487,7 @@ void ExplodeObject::SetDebrisModel
const char *ptr;
// there could be multiple space delimited models, so we need to search for the spaces.
strcpy( string, ev->GetString( 1 ) );
Q_strncpyz( string, ev->GetString( 1 ), sizeof( string ) );
ptr = strtok( string, " " );
while ( ptr )
{

View file

@ -104,10 +104,10 @@ void G_AddBot(unsigned int num, saved_bot_t* saved)
}
else
{
sprintf( botName, "bot%d", clientNum - maxclients->integer + 1 );
Com_sprintf( botName, sizeof( botName ), "bot%d", clientNum - maxclients->integer + 1 );
}
sprintf( challenge, "%d", clientNum - maxclients->integer + 1 );
Com_sprintf( challenge, sizeof( challenge ), "%d", clientNum - maxclients->integer + 1 );
e->s.clientNum = clientNum;
e->s.number = clientNum;

View file

@ -94,7 +94,7 @@ void QDECL G_Printf(const char *fmt, ...)
char text[1024];
va_start(argptr, fmt);
vsprintf(text, fmt, argptr);
Q_vsnprintf(text, sizeof(text), fmt, argptr);
va_end(argptr);
gi.Printf(text);
@ -111,7 +111,7 @@ void QDECL G_Error(const char *fmt, ...)
char text[1024];
va_start(argptr, fmt);
vsprintf(text, fmt, argptr);
Q_vsnprintf(text, sizeof(text), fmt, argptr);
va_end(argptr);
gi.Error(ERR_DROP, text);
@ -128,7 +128,7 @@ void QDECL G_Error(int type, const char *fmt, ...)
char text[1024];
va_start(argptr, fmt);
vsprintf(text, fmt, argptr);
Q_vsnprintf(text, sizeof(text), fmt, argptr);
va_end(argptr);
// need to manually crash otherwise visual studio fuck up with the stack pointer...
@ -336,7 +336,7 @@ void QDECL Com_Error(int level, const char *error, ...)
char text[1024];
va_start(argptr, error);
vsprintf(text, error, argptr);
Q_vsnprintf(text, sizeof(text), error, argptr);
va_end(argptr);
G_Error("%s", text);
@ -348,7 +348,7 @@ void QDECL Com_Printf(const char *msg, ...)
char text[1024];
va_start(argptr, msg);
vsprintf(text, msg, argptr);
Q_vsnprintf(text, sizeof(text), msg, argptr);
va_end(argptr);
gi.DPrintf("%s", text);
@ -1894,7 +1894,7 @@ void G_ExitLevel(void)
gi.SendConsoleCommand(command);
} else if (!Q_stricmpn(level.nextmap, "vstr", 4)) {
// alias on another map
strcpy(command, level.nextmap);
Q_strncpyz(command, level.nextmap, sizeof(command));
gi.SendConsoleCommand(command);
} else // use the level.nextmap variable
{

View file

@ -853,8 +853,8 @@ const char *G_FixTIKIPath(const char *in) {
if(gi.FS_ReadFile( in, &buffer ) > 0) {
return in;
}
strcpy(path,"models/");
strcat(path,in);
Q_strncpyz(path,"models/", sizeof(path));
Q_strcat(path,sizeof(path),in);
if( gi.FS_ReadFile( in, &buffer ) > 0 ) {
return path;
}

View file

@ -1379,9 +1379,9 @@ char *CanonicalTikiName(const char *szInName)
static char filename[1024];
if (*szInName && Q_stricmpn("models/", szInName, 7)) {
sprintf(filename, "models/%s", szInName);
Com_sprintf(filename, sizeof(filename), "models/%s", szInName);
} else {
strcpy(filename, szInName);
Q_strncpyz(filename, szInName, sizeof(filename));
}
gi.FS_CanonicalFilename(filename);
@ -1450,7 +1450,7 @@ void CacheResource(const char *stuff)
}
}
strcpy(filename, stuff);
Q_strncpyz(filename, stuff, sizeof(filename));
gi.FS_CanonicalFilename(filename);
if (strstr(filename, ".wav") || strstr(filename, ".mp3")) {
@ -2225,7 +2225,7 @@ void G_WarnPlayer(Player *player, const char *format, ...)
va_list va;
va_start(va, format);
vsprintf(buffer, format, va);
Q_vsnprintf(buffer, sizeof(buffer), format, va);
va_end(va);
gi.SendServerCommand(player->client->ps.clientNum, "print \"%s\"\n", buffer);

View file

@ -929,7 +929,7 @@ void ScriptThreadLabel::Set(const char *label)
return;
}
strcpy(buffer, label);
Q_strncpyz(buffer, label, sizeof(buffer));
while (true) {
if (p[0] == ':' && p[1] == ':') {
@ -1022,7 +1022,7 @@ void ScriptThreadLabel::SetScript(const char *label)
return;
}
strcpy(buffer, label);
Q_strncpyz(buffer, label, sizeof(buffer));
script = buffer;
while (true) {

View file

@ -779,7 +779,7 @@ void Hud::TimerThink()
#else
if( !*shader ) {
#endif
sprintf( buffer, string, minutes, seconds );
Com_sprintf( buffer, sizeof( buffer ), string, minutes, seconds );
SetText( buffer );
} else {

View file

@ -298,7 +298,7 @@ void SVCmd_WriteIP_f
byte b[ 4 ];
int i;
sprintf( name, "%s/listip.cfg", GAMEVERSION );
Com_sprintf( name, sizeof( name ), "%s/listip.cfg", GAMEVERSION );
gi.SendServerCommand( 0, "print \"Writing %s.\n\"", name );
f = fopen( name, "wb" );

View file

@ -751,7 +751,7 @@ void Item::setName(const char *i)
item_name = i;
item_index = gi.itemindex(i);
strcpy(edict->entname, i);
Q_strncpyz(edict->entname, i, sizeof(edict->entname));
prefix = GetItemPrefix(item_name);
if (prefix) {

View file

@ -1164,7 +1164,7 @@ void Level::SpawnEntities(char *entities, int svsTime)
Q_strncpyz(ent->edict->entname, ent->getClassID(), sizeof(ent->edict->entname));
ent->PostEvent(EV_Entity_Start, -1.0, 0);
sprintf(name, "i%d", radnum);
Com_sprintf(name, sizeof(name), "i%d", radnum);
gi.LoadResource(name);
}
}
@ -1957,7 +1957,7 @@ void Level::SetupMaplist()
return;
}
strcpy(buffer, m_voteString.c_str());
Q_strncpyz(buffer, m_voteString.c_str(), sizeof(buffer));
for (p = strtok(buffer, delim); p; p = strtok(NULL, delim)) {
if (strstr(p, "g_gametype")) {

View file

@ -2522,12 +2522,12 @@ void Player::InitModelFps(void)
char model_name[MAX_STRING_TOKENS];
char *model_replace;
strcpy(model_name, model.c_str());
Q_strncpyz(model_name, model.c_str(), sizeof(model_name));
size_t len = strlen(model_name);
model_replace = model_name + len - 4;
strcpy(model_replace, "_fps.tik");
Q_strncpyz(model_replace, "_fps.tik", sizeof(model_name) - (model_replace - model_name));
m_fpsTiki = gi.modeltiki(model_name);
}
@ -3272,14 +3272,14 @@ void Player::SetStopwatch(int iDuration, stopWatchType_t type)
}
}
sprintf(szCmd, "stopwatch %i %i %i", iStartTime, iDuration, type);
Com_sprintf(szCmd, sizeof(szCmd), "stopwatch %i %i %i", iStartTime, iDuration, type);
} else {
iStartTime = 0;
if (iDuration) {
iStartTime = (int)level.svsFloatTime;
}
sprintf(szCmd, "stopwatch %i %i", iStartTime, iDuration);
Com_sprintf(szCmd, sizeof(szCmd), "stopwatch %i %i", iStartTime, iDuration);
}
gi.SendServerCommand(edict - g_entities, szCmd);
@ -5670,7 +5670,7 @@ void Player::GiveAllCheat(Event *ev)
if (gi.FS_ReadFile("global/giveall.scr", (void **)&buf, true) != -1) {
buffer = buf;
while (1) {
strcpy(com_token, COM_ParseExt(&buffer, qtrue));
Q_strncpyz(com_token, COM_ParseExt(&buffer, qtrue), sizeof(com_token));
if (!com_token[0]) {
break;
@ -5681,7 +5681,7 @@ void Player::GiveAllCheat(Event *ev)
// get the rest of the line
while (1) {
strcpy(com_token, COM_ParseExt(&buffer, qfalse));
Q_strncpyz(com_token, COM_ParseExt(&buffer, qfalse), sizeof(com_token));
if (!com_token[0]) {
break;
}
@ -8631,49 +8631,49 @@ void Player::EnsurePlayerHasAllowedWeapons()
return;
}
strcpy(client->pers.dm_primary, "rifle");
Q_strncpyz(client->pers.dm_primary, "rifle", sizeof(client->pers.dm_primary));
} else if (!Q_stricmp(client->pers.dm_primary, "rifle")) {
if (!(dmflags->integer & DF_WEAPON_NO_RIFLE)) {
return;
}
strcpy(client->pers.dm_primary, "smg");
Q_strncpyz(client->pers.dm_primary, "smg", sizeof(client->pers.dm_primary));
} else if (!Q_stricmp(client->pers.dm_primary, "smg")) {
if (!(dmflags->integer & DF_WEAPON_NO_RIFLE)) {
return;
}
strcpy(client->pers.dm_primary, "mg");
Q_strncpyz(client->pers.dm_primary, "mg", sizeof(client->pers.dm_primary));
} else if (!Q_stricmp(client->pers.dm_primary, "mg")) {
if (!(dmflags->integer & DF_WEAPON_NO_RIFLE)) {
return;
}
strcpy(client->pers.dm_primary, "shotgun");
Q_strncpyz(client->pers.dm_primary, "shotgun", sizeof(client->pers.dm_primary));
} else if (!Q_stricmp(client->pers.dm_primary, "shotgun")) {
if (!(dmflags->integer & DF_WEAPON_NO_RIFLE)) {
return;
}
strcpy(client->pers.dm_primary, "heavy");
Q_strncpyz(client->pers.dm_primary, "heavy", sizeof(client->pers.dm_primary));
} else if (!Q_stricmp(client->pers.dm_primary, "heavy")) {
if (!(dmflags->integer & DF_WEAPON_NO_RIFLE)) {
return;
}
strcpy(client->pers.dm_primary, "landmine");
Q_strncpyz(client->pers.dm_primary, "landmine", sizeof(client->pers.dm_primary));
} else if (!Q_stricmp(client->pers.dm_primary, "landmine")) {
if (QueryLandminesAllowed()) {
return;
}
strcpy(client->pers.dm_primary, "sniper");
Q_strncpyz(client->pers.dm_primary, "sniper", sizeof(client->pers.dm_primary));
}
}
gi.cvar_set("dmflags", va("%i", dmflags->integer & ~DF_WEAPON_NO_RIFLE));
Com_Printf("No valid weapons -- re-allowing the rifle\n");
strcpy(client->pers.dm_primary, "rifle");
Q_strncpyz(client->pers.dm_primary, "rifle", sizeof(client->pers.dm_primary));
}
void Player::EquipWeapons()
@ -10471,12 +10471,12 @@ void Player::EventDMMessage(Event *ev)
}
}
strcpy(szPrintString, "print \"" HUD_MESSAGE_CHAT_WHITE);
Q_strncpyz(szPrintString, "print \"" HUD_MESSAGE_CHAT_WHITE, sizeof(szPrintString));
if (m_bSpectator) {
if (iMode <= 0) {
strcat(szPrintString, gi.CL_LV_ConvertString("(spectator)"));
strcat(szPrintString, " ");
Q_strcat(szPrintString, sizeof(szPrintString), gi.CL_LV_ConvertString("(spectator)"));
Q_strcat(szPrintString, sizeof(szPrintString), " ");
} else if (iMode <= game.maxclients) {
ent = &g_entities[iMode - 1];
@ -10496,8 +10496,8 @@ void Player::EventDMMessage(Event *ev)
}
} else if (IsDead() || m_bTempSpectator) {
if (iMode <= 0) {
strcat(szPrintString, gi.CL_LV_ConvertString("(dead)"));
strcat(szPrintString, " ");
Q_strcat(szPrintString, sizeof(szPrintString), gi.CL_LV_ConvertString("(dead)"));
Q_strcat(szPrintString, sizeof(szPrintString), " ");
} else if (iMode <= game.maxclients) {
ent = &g_entities[iMode - 1];
@ -10516,22 +10516,22 @@ void Player::EventDMMessage(Event *ev)
}
}
} else if (iMode < 0) {
strcat(szPrintString, gi.CL_LV_ConvertString("(team)"));
strcat(szPrintString, " ");
Q_strcat(szPrintString, sizeof(szPrintString), gi.CL_LV_ConvertString("(team)"));
Q_strcat(szPrintString, sizeof(szPrintString), " ");
} else if (iMode > 0) {
strcat(szPrintString, gi.CL_LV_ConvertString("(private)"));
strcat(szPrintString, " ");
Q_strcat(szPrintString, sizeof(szPrintString), gi.CL_LV_ConvertString("(private)"));
Q_strcat(szPrintString, sizeof(szPrintString), " ");
}
strcat(szPrintString, client->pers.netname);
Q_strcat(szPrintString, sizeof(szPrintString), client->pers.netname);
if (bInstaMessage) {
strcat(szPrintString, ": ");
strcat(szPrintString, gi.LV_ConvertString(pTmpInstantMsg));
Q_strcat(szPrintString, sizeof(szPrintString), ": ");
Q_strcat(szPrintString, sizeof(szPrintString), gi.LV_ConvertString(pTmpInstantMsg));
} else {
bool met_comment;
strcat(szPrintString, ":");
Q_strcat(szPrintString, sizeof(szPrintString), ":");
iStringLength = strlen(szPrintString);
for (i = 2; i <= ev->NumArgs(); i++) {
@ -10556,12 +10556,12 @@ void Player::EventDMMessage(Event *ev)
return;
}
strcat(szPrintString, " ");
strcat(szPrintString, gi.LV_ConvertString(sToken));
Q_strcat(szPrintString, sizeof(szPrintString), " ");
Q_strcat(szPrintString, sizeof(szPrintString), gi.LV_ConvertString(sToken));
}
}
strcat(szPrintString, "\n");
Q_strcat(szPrintString, sizeof(szPrintString), "\n");
// ignore names containing comments
if (strstr(client->pers.netname, "//")
@ -10800,7 +10800,7 @@ str Player::GetBattleLanguageLocalFolks()
break;
}
strcpy(p, ", ");
Q_strncpyz(p, ", ", sizeof(buf) - (p - buf));
p += 2;
curP = p;
remaining -= 2;
@ -10811,7 +10811,7 @@ str Player::GetBattleLanguageLocalFolks()
break;
}
strcpy(p, client->pers.netname);
Q_strncpyz(p, client->pers.netname, sizeof(buf) - (p - buf));
p += length;
remaining -= length;
pFolk = pPlayer;
@ -10819,8 +10819,8 @@ str Player::GetBattleLanguageLocalFolks()
}
if (curP && remaining >= 2) {
strcpy(curP, "and ");
strcpy(curP + strlen(curP), pFolk->client->pers.netname);
Q_strncpyz(curP, "and ", sizeof(buf) - (curP - buf));
Q_strncpyz(curP + strlen(curP), pFolk->client->pers.netname, sizeof(buf) - (curP + strlen(curP) - buf));
} else if (!pFolk) {
return "nobody";
}
@ -11605,9 +11605,9 @@ void Player::UserSelectWeapon(bool bWait)
}
if (bWait) {
strcpy(buf, "stufftext \"wait 250;pushmenu ");
Q_strncpyz(buf, "stufftext \"wait 250;pushmenu ", sizeof(buf));
} else {
strcpy(buf, "stufftext \"pushmenu ");
Q_strncpyz(buf, "stufftext \"pushmenu ", sizeof(buf));
}
if (dmflags->integer & DF_WEAPON_NO_RIFLE && dmflags->integer & DF_WEAPON_NO_SNIPER
@ -11616,24 +11616,24 @@ void Player::UserSelectWeapon(bool bWait)
&& dmflags->integer & DF_WEAPON_NO_LANDMINE && !QueryLandminesAllowed()) {
gi.cvar_set("dmflags", va("%i", dmflags->integer & ~DF_WEAPON_NO_RIFLE));
Com_Printf("No valid weapons -- re-allowing the rifle\n");
strcpy(client->pers.dm_primary, "rifle");
Q_strncpyz(client->pers.dm_primary, "rifle", sizeof(client->pers.dm_primary));
}
switch (nationality) {
case NA_BRITISH:
strcat(buf, "SelectPrimaryWeapon_british\"");
Q_strcat(buf, sizeof(buf), "SelectPrimaryWeapon_british\"");
break;
case NA_RUSSIAN:
strcat(buf, "SelectPrimaryWeapon_russian\"");
Q_strcat(buf, sizeof(buf), "SelectPrimaryWeapon_russian\"");
break;
case NA_GERMAN:
strcat(buf, "SelectPrimaryWeapon_german\"");
Q_strcat(buf, sizeof(buf), "SelectPrimaryWeapon_german\"");
break;
case NA_ITALIAN:
strcat(buf, "SelectPrimaryWeapon_italian\"");
Q_strcat(buf, sizeof(buf), "SelectPrimaryWeapon_italian\"");
break;
default:
strcat(buf, "SelectPrimaryWeapon\"");
Q_strcat(buf, sizeof(buf), "SelectPrimaryWeapon\"");
break;
}

View file

@ -803,7 +803,7 @@ GameScript *ScriptMaster::GetGameScriptInternal(str& filename)
gi.Error(ERR_DROP, "Script filename '%s' exceeds maximum length of %d\n", filename.c_str(), MAX_QPATH);
}
strcpy(filepath, filename.c_str());
Q_strncpyz(filepath, filename.c_str(), sizeof(filepath));
gi.FS_CanonicalFilename(filepath);
filename = filepath;
@ -1111,30 +1111,30 @@ void ScriptMaster::PrintStatus(void)
ScriptVM *vm;
for (vm = scriptClass->m_Threads; vm != NULL; vm = vm->next) {
sprintf(szBuffer, "%.7d", iThreadNum);
Com_sprintf(szBuffer, sizeof(szBuffer), "%.7d", iThreadNum);
status += szBuffer + str(" ");
switch (vm->ThreadState()) {
case THREAD_RUNNING:
sprintf(szBuffer, "%8s", "running");
Com_sprintf(szBuffer, sizeof(szBuffer), "%8s", "running");
iThreadRunning++;
break;
case THREAD_WAITING:
sprintf(szBuffer, "%8s", "waiting");
Com_sprintf(szBuffer, sizeof(szBuffer), "%8s", "waiting");
iThreadWaiting++;
break;
case THREAD_SUSPENDED:
sprintf(szBuffer, "%8s", "suspended");
Com_sprintf(szBuffer, sizeof(szBuffer), "%8s", "suspended");
iThreadSuspended++;
break;
}
status += szBuffer;
sprintf(szBuffer, "%15s", vm->Label().c_str());
Com_sprintf(szBuffer, sizeof(szBuffer), "%15s", vm->Label().c_str());
status += szBuffer + str(" ");
sprintf(szBuffer, "%15s", vm->Filename().c_str());
Com_sprintf(szBuffer, sizeof(szBuffer), "%15s", vm->Filename().c_str());
status += szBuffer;
status += "\n";

View file

@ -4726,7 +4726,7 @@ void ScriptThread::GetPlayerIP(Event *ev)
ip = ent->client->pers.ip;
sprintf(ip_buff, "%s:%i", ip, ent->client->pers.port);
Com_sprintf(ip_buff, sizeof(ip_buff), "%s:%i", ip, ent->client->pers.port);
ev->AddString(ip_buff);
}
@ -5348,7 +5348,7 @@ void ScriptThread::FileOpen(Event *ev)
return;
} else {
ev->AddInteger((int)(size_t)f);
sprintf(buf, "%i", scriptfiles->integer + 1);
Com_sprintf(buf, sizeof(buf), "%i", scriptfiles->integer + 1);
gi.cvar_set("sv_scriptfiles", buf);
return;
}
@ -5408,7 +5408,7 @@ void ScriptThread::FileClose(Event *ev)
if (ret == 0) {
ev->AddInteger(0);
sprintf(buf, "%i", scriptfiles->integer - 1);
Com_sprintf(buf, sizeof(buf), "%i", scriptfiles->integer - 1);
gi.cvar_set("sv_scriptfiles", buf);
return;
} else {
@ -6252,7 +6252,7 @@ void ScriptThread::FlagInit(Event *ev)
flag = new Flag;
flag->bSignaled = false;
strcpy(flag->flagName, name);
Q_strncpyz(flag->flagName, name, sizeof(flag->flagName));
}
void ScriptThread::FlagSet(Event *ev)
@ -6603,7 +6603,7 @@ void ScriptThread::EventFmod(Event *ev)
ev->AddFloat((float)res);
}
int checkMD5(const char *filepath, char *md5Hash)
int checkMD5(const char *filepath, char *md5Hash, size_t destSize)
{
md5_state_t state;
md5_byte_t digest[16];
@ -6652,7 +6652,7 @@ int checkMD5(const char *filepath, char *md5Hash)
md5_finish(&state, digest);
for (di = 0; di < 16; ++di) {
sprintf(md5Hash + di * 2, "%02x", digest[di]);
Com_sprintf(md5Hash + di * 2, destSize - di * 2, "%02x", digest[di]);
}
gi.Free(buff);
@ -6660,7 +6660,7 @@ int checkMD5(const char *filepath, char *md5Hash)
return 0;
}
int checkMD5String(const char *string, char *md5Hash)
int checkMD5String(const char *string, char *md5Hash, size_t destSize)
{
md5_state_t state;
md5_byte_t digest[16];
@ -6685,7 +6685,7 @@ int checkMD5String(const char *string, char *md5Hash)
md5_finish(&state, digest);
for (di = 0; di < 16; ++di) {
sprintf(md5Hash + di * 2, "%02x", digest[di]);
Com_sprintf(md5Hash + di * 2, destSize - di * 2, "%02x", digest[di]);
}
gi.Free(buff);
@ -6705,7 +6705,7 @@ void ScriptThread::Md5File(Event *ev)
filename = ev->GetString(1);
ret = checkMD5(filename, hash);
ret = checkMD5(filename, hash, sizeof(hash));
if (ret != 0) {
ev->AddInteger(-1);
throw ScriptException("Error while generating MD5 checksum for file - md5file!\n");
@ -6742,7 +6742,7 @@ void ScriptThread::Md5String(Event *ev)
text = ev->GetString(1);
ret = checkMD5String(text, hash);
ret = checkMD5String(text, hash, sizeof(hash));
if (ret != 0) {
ev->AddInteger(-1);
throw ScriptException("Error while generating MD5 checksum for strin!\n");
@ -6937,7 +6937,7 @@ void ScriptThread::GetTime(Event *ev)
timediff = timearray[0] - gmttime;
sprintf(buff, "%02i:%02i:%02i", (int)timearray[0], (int)timearray[1], (int)timearray[2]);
Com_sprintf(buff, sizeof(buff), "%02i:%02i:%02i", (int)timearray[0], (int)timearray[1], (int)timearray[2]);
ev->AddString(buff);
}

View file

@ -1078,7 +1078,7 @@ int SimpleActor::GetEmotionAnim(void)
default:
char assertStr[16317] = {0};
strcpy(assertStr, "\"Unknown value for m_EmotionMode in SimpleActor::GetEmotionAnim\"\n\tMessage: ");
Q_strncpyz(assertStr, "\"Unknown value for m_EmotionMode in SimpleActor::GetEmotionAnim\"\n\tMessage: ", sizeof(assertStr));
Q_strcat(assertStr, sizeof(assertStr), DumpCallTrace(""));
assert(!assertStr);
return -1;
@ -1101,7 +1101,7 @@ int SimpleActor::GetEmotionAnim(void)
default:
char assertStr[16317] = {0};
strcpy(assertStr, "\"Unknown value for m_csMood in SimpleActor::GetEmotionAnim\"\n\tMessage: ");
Q_strncpyz(assertStr, "\"Unknown value for m_csMood in SimpleActor::GetEmotionAnim\"\n\tMessage: ", sizeof(assertStr));
Q_strcat(assertStr, sizeof(assertStr), DumpCallTrace(""));
assert(!assertStr);
return -1;

View file

@ -271,7 +271,7 @@ void Alias_ListAddParms(AliasListNode_t* node, const char* parameters)
}
node->subtitle = Z_TagMalloc(strlen(token) + 1, TAG_TIKI);
strcpy(node->subtitle, token);
Q_strncpyz(node->subtitle, token, sizeof(node->subtitle));
}
else if (!Q_stricmp(token, "pitch"))
{

View file

@ -202,7 +202,7 @@ void CLASS_Print(FILE *class_file, const char *fmt, ...)
char text[1024];
va_start(argptr, fmt);
vsprintf(text, fmt, argptr);
Q_vsnprintf(text, sizeof(text), fmt, argptr);
va_end(argptr);
if (class_file) {
@ -238,7 +238,7 @@ void Class::warning(const char *function, const char *format, ...) const
va_list va;
va_start(va, format);
vsprintf(buffer, format, va);
Q_vsnprintf(buffer, sizeof(buffer), format, va);
classname = classinfo()->classname;
@ -259,7 +259,7 @@ void Class::error(const char *function, const char *fmt, ...) const
char text[1024];
va_start(argptr, fmt);
vsprintf(text, fmt, argptr);
Q_vsnprintf(text, sizeof(text), fmt, argptr);
va_end(argptr);
if (getClassID()) {

View file

@ -311,14 +311,14 @@ qboolean CM_LoadFCM(const char *szName, cfencemask_t **pMask)
m = (cfencemask_t *)Hunk_Alloc(sizeof(cfencemask_t), h_dontcare);
*pMask = m;
strcpy(m->name, szName);
Q_strncpyz(m->name, szName, sizeof(m->name));
m->iWidth = header.iWidth;
m->iHeight = header.iHeight;
m->pData = (byte *)Hunk_Alloc(iDataSize, h_dontcare);
FS_Read(m->pData, iDataSize, h);
FS_FCloseFile(h);
sprintf(tempName, "f%s", szName);
Com_sprintf(tempName, sizeof(tempName), "f%s", szName);
UI_LoadResource(tempName);
return qtrue;
@ -483,7 +483,7 @@ qboolean CM_GenerateFenceMask(const char *szName, cfencemask_t **pMask)
// load the mask if it has transparence and is opaque
if (bHasOpaque && bHasTrans) {
*pMask = Hunk_Alloc((iMaskSize >> 3) + sizeof(cfencemask_t), h_dontcare);
strcpy((*pMask)->name, szName);
Q_strncpyz((*pMask)->name, szName, sizeof((*pMask)->name));
(*pMask)->iWidth = iWidth;
(*pMask)->iHeight = iHeight;
(*pMask)->pData = (byte *)((byte *)*pMask + sizeof(**pMask));
@ -564,7 +564,7 @@ cfencemask_t *CM_GetFenceMask(const char *szMaskName)
if (save || !CM_LoadFCM(szMaskName, &pMask)) {
if (!CM_GenerateFenceMask(szMaskName, &pMask)) {
pMask = (cfencemask_t *)Hunk_Alloc(sizeof(cfencemask_t), h_dontcare);
strcpy(pMask->name, szMaskName);
Q_strncpyz(pMask->name, szMaskName, sizeof(pMask->name));
pMask->pData = NULL;
pMask->pNext = cm.fencemasks;
cm.fencemasks = pMask;

View file

@ -121,7 +121,7 @@ void CMod_LoadShaders( gamelump_t *l, int **shaderSubdivisions ) {
out = cm.shaders;
for ( i=0 ; i<count ; i++, in++, out++ ) {
strcpy( out->shader, in->shader );
Q_strncpyz( out->shader, in->shader, sizeof( out->shader ) );
out->contentFlags = LittleLong( in->contentFlags );
out->surfaceFlags = LittleLong( in->surfaceFlags );
out->mask = CM_GetFenceMask( in->fenceMaskImage );
@ -678,7 +678,7 @@ void CMod_LoadPatches( gamelump_t *surfs, gamelump_t *verts, int *shaderSubdivis
// create the internal facet structure
patch->pc = CM_GeneratePatchCollide( width, height, points, patch->subdivisions );
sprintf(tempName, "s%d", i);
Com_sprintf(tempName, sizeof(tempName), "s%d", i);
UI_LoadResource(tempName);
}

View file

@ -146,7 +146,7 @@ obfuscation_t* CM_SetupObfuscationMapping() {
}
obfuscation = &list[j];
strcpy(obfuscation->name, token);
Q_strncpyz(obfuscation->name, token, sizeof(obfuscation->name));
token = CM_NextCsvToken(&text, qfalse);
if (!text) {

View file

@ -407,7 +407,7 @@ void QDECL Com_Error( int code, const char *fmt, ... ) {
com_errorEntered = qtrue;
va_start (argptr,fmt);
vsprintf (com_errorMessage,fmt,argptr);
Q_vsnprintf (com_errorMessage,sizeof(com_errorMessage),fmt,argptr);
va_end (argptr);
if (code != ERR_DISCONNECT && code != ERR_NEED_CD)

View file

@ -308,8 +308,8 @@ void Configurator::WriteData( char **data, size_t *size )
currentSize += len;
currentData = new char[ currentSize + 1 ];
strncpy( currentData, oldData, offset );
sprintf( currentData + offset, offset ? "\n\n[%s]" : "[%s]", section->name.c_str() );
strcpy( currentData + offset + len, oldData + offset );
Com_sprintf( currentData + offset, currentSize + 1 - offset, offset ? "\n\n[%s]" : "[%s]", section->name.c_str() );
Q_strncpyz( currentData + offset + len, oldData + offset, currentSize + 1 - offset - len );
if( currentData != oldData ) delete[] oldData;
}
@ -360,8 +360,8 @@ void Configurator::WriteData( char **data, size_t *size )
currentSize += len;
currentData = new char[ currentSize + 1 ];
strncpy( currentData, oldData, offset );
sprintf( currentData + offset, "\n%s[%d]=%s", key->name.c_str(), k, value.c_str() );
strcpy( currentData + offset + len, oldData + offset2 );
Com_sprintf( currentData + offset, currentSize + 1 - offset, "\n%s[%d]=%s", key->name.c_str(), k, value.c_str() );
Q_strncpyz( currentData + offset + len, oldData + offset2, currentSize + 1 - offset - len );
if( currentData != oldData ) delete[] oldData;
}
@ -393,8 +393,8 @@ void Configurator::WriteData( char **data, size_t *size )
currentSize += len;
currentData = new char[ currentSize + 1 ];
strncpy( currentData, oldData, offset );
sprintf( currentData + offset, "\n%s=%s", key->name.c_str(), value.c_str() );
strcpy( currentData + offset + len, oldData + offset2 );
Com_sprintf( currentData + offset, currentSize + 1 - offset "\n%s=%s", key->name.c_str(), value.c_str() );
Q_strncpyz( currentData + offset + len, oldData + offset2, currentSize + 1 - offset - len );
if( currentData != oldData ) delete[] oldData;
}
@ -445,18 +445,18 @@ void Configurator::WriteData2( char **data, size_t *size )
currentSize = tlen + 1024;
currentData = new char[ currentSize ];
p = currentData + ( p - oldData );
strcpy( currentData, oldData );
Q_strncpyz( currentData, oldData, currentSize );
delete[] oldData;
}
if( i == 1 )
{
p += sprintf( p, "[%s]\n", section->name.c_str() );
p += Com_sprintf( p, currentSize - ( p - currentData ), "[%s]\n", section->name.c_str() );
}
else
{
p += sprintf( p, "\n[%s]\n", section->name.c_str() );
p += Com_sprintf( p, currentSize - ( p - currentData ), "\n[%s]\n", section->name.c_str() );
}
for( j = 0; j < section->key.NumObjects(); j++ )
@ -500,7 +500,7 @@ void Configurator::WriteData2( char **data, size_t *size )
delete[] oldData;
}
p += sprintf( p, "%s[%d]=%s\n", key->name.c_str(), k, value.c_str() );
p += Com_sprintf( p, currentSize - ( p - currentData ), "%s[%d]=%s\n", key->name.c_str(), k, value.c_str() );
}
}
}
@ -524,7 +524,7 @@ void Configurator::WriteData2( char **data, size_t *size )
delete[] oldData;
}
p += sprintf( p, "%s=%s\n", key->name.c_str(), value.c_str() );
p += Com_sprintf( p, currentSize - ( p - currentData ), "%s=%s\n", key->name.c_str(), value.c_str() );
}
}
}
@ -585,7 +585,7 @@ bool Configurator::FindData( int type, const char *s, const char *k, size_t *off
arrayindex = GetKeyArray( key );
if( arrayindex >= 0 )
{
sprintf( key, "%s[%d]", key, arrayindex );
Com_sprintf( key, sizeof( key ), "%s[%d]", key, arrayindex );
}
if( type == LINE_VALUE && bFoundSection && !Q_stricmp( k, key ) )

View file

@ -748,7 +748,7 @@ void EV_Print(FILE *stream, const char *format, ...)
va_start(va, format);
vsprintf(buffer, format, va);
Q_vsnprintf(buffer, sizeof(buffer), format, va);
if (stream) {
fprintf(stream, "%s", buffer);
@ -863,7 +863,7 @@ void EventDef::Error(const char *format, ...)
va_list va;
va_start(va, format);
vsprintf(buffer, format, va);
Q_vsnprintf(buffer, sizeof(buffer), format, va);
va_end(va);
EVENT_Printf("^~^~^ Game: '%s' : %s\n", command.c_str(), buffer);
@ -1018,7 +1018,7 @@ void EventDef::SetupDocumentation(void)
//
// store off all the names
//
strcpy(argumentNames, argument_names);
Q_strncpyz(argumentNames, argument_names, sizeof(argumentNames));
namePtr = strtok(argumentNames, " ");
while (namePtr != NULL) {
argNames.AddObject(str(namePtr));

View file

@ -345,7 +345,7 @@ void COM_ParseError( char *format, ... )
static char string[4096];
va_start (argptr, format);
vsprintf (string, format, argptr);
Q_vsnprintf (string, sizeof(string), format, argptr);
va_end (argptr);
Com_Printf("ERROR: %s, line %d: %s\n", com_parsename, com_lines, string);
@ -357,7 +357,7 @@ void COM_ParseWarning( char *format, ... )
static char string[4096];
va_start (argptr, format);
vsprintf (string, format, argptr);
Q_vsnprintf (string, sizeof(string), format, argptr);
va_end (argptr);
Com_Printf("WARNING: %s, line %d: %s\n", com_parsename, com_lines, string);

View file

@ -181,7 +181,7 @@ void Script::MarkPosition(scriptmarker_t *mark)
mark->tokenready = tokenready;
mark->offset = script_p - buffer;
mark->line = line;
strcpy(mark->token, token);
Q_strncpyz(mark->token, token, sizeof(mark->token));
}
/*
@ -199,7 +199,7 @@ void Script::RestorePosition(const scriptmarker_t *mark)
tokenready = mark->tokenready;
script_p = buffer + mark->offset;
line = mark->line;
strcpy(token, mark->token);
Q_strncpyz(token, mark->token, sizeof(token));
assert(script_p <= end_p);
if (script_p > end_p) {
@ -660,7 +660,7 @@ const char *Script::GetMacroString(const char *theMacroName)
}
char tmpstr[255], *sptr = tmpstr;
strcpy(tmpstr, theMacroName);
Q_strncpyz(tmpstr, theMacroName, sizeof(tmpstr));
tmpstr[strlen(tmpstr) - 1] = 0;
sptr++;
@ -741,7 +741,7 @@ char *Script::EvaluateMacroString(const char *theMacroString)
bufferptr++;
}
sprintf(evalText, "%f", value);
Com_sprintf(evalText, sizeof(evalText), "%f", value);
return evalText;
}
@ -1076,7 +1076,7 @@ int Script::LinesInFile(void)
temp_tokenready = tokenready;
temp_script_p = script_p;
temp_line = line;
strcpy(temp_token, token);
Q_strncpyz(temp_token, token, sizeof(temp_token));
numentries = 0;
@ -1089,7 +1089,7 @@ int Script::LinesInFile(void)
tokenready = temp_tokenready;
script_p = temp_script_p;
line = temp_line;
strcpy(token, temp_token);
Q_strncpyz(token, temp_token, sizeof(token));
return numentries;
}

View file

@ -218,7 +218,7 @@ str operator+(const str& a, const float b)
str result(a);
sprintf(text, "%f", b);
snprintf(text, sizeof(text), "%f", b);
result.append(text);
return result;
@ -230,7 +230,7 @@ str operator+(const str& a, const int b)
str result(a);
sprintf(text, "%d", b);
snprintf(text, sizeof(text), "%d", b);
result.append(text);
return result;
@ -242,7 +242,7 @@ str operator+(const str& a, const unsigned b)
str result(a);
sprintf(text, "%u", b);
snprintf(text, sizeof(text), "%u", b);
result.append(text);
return result;
@ -252,7 +252,7 @@ str& str::operator+=(const float a)
{
char text[20];
sprintf(text, "%f", a);
snprintf(text, sizeof(text), "%f", a);
append(text);
return *this;
@ -262,7 +262,7 @@ str& str::operator+=(const int a)
{
char text[20];
sprintf(text, "%d", a);
snprintf(text, sizeof(text), "%d", a);
append(text);
return *this;
@ -272,7 +272,7 @@ str& str::operator+=(const unsigned a)
{
char text[20];
sprintf(text, "%u", a);
snprintf(text, sizeof(text), "%u", a);
append(text);
return *this;
@ -536,7 +536,7 @@ void str::snprintf(char *dst, int size, const char *fmt, ...)
va_list argptr;
va_start(argptr, fmt);
len = vsprintf(buffer, fmt, argptr);
len = vsnprintf(buffer, sizeof(buffer), fmt, argptr);
va_end(argptr);
assert(len < size);

View file

@ -293,7 +293,7 @@ inline str::str(const float num)
char text[32];
size_t len;
sprintf(text, "%.3f", num);
snprintf(text, sizeof(text), "%.3f", num);
len = strlen(text);
EnsureAlloced(len + 1);
strcpy(m_data->data, text);
@ -306,7 +306,7 @@ inline str::str(const int num)
char text[32];
size_t len;
sprintf(text, "%d", num);
snprintf(text, sizeof(text), "%d", num);
len = strlen(text);
EnsureAlloced(len + 1);
strcpy(m_data->data, text);
@ -319,7 +319,7 @@ inline str::str(const unsigned int num)
char text[32];
size_t len;
sprintf(text, "%u", num);
snprintf(text, sizeof(text), "%u", num);
len = strlen(text);
EnsureAlloced(len + 1);
strcpy(m_data->data, text);
@ -332,7 +332,7 @@ inline str::str(const long num)
char text[64];
size_t len;
sprintf(text, "%ld", num);
snprintf(text, sizeof(text), "%ld", num);
len = strlen(text);
EnsureAlloced(len + 1);
strcpy(m_data->data, text);
@ -345,7 +345,7 @@ inline str::str(const unsigned long num)
char text[64];
size_t len;
sprintf(text, "%lu", num);
snprintf(text, sizeof(text), "%lu", num);
len = strlen(text);
EnsureAlloced(len + 1);
strcpy(m_data->data, text);
@ -358,7 +358,7 @@ inline str::str(const long long num)
char text[64];
size_t len;
sprintf(text, "%lld", num);
snprintf(text, sizeof(text), "%lld", num);
len = strlen(text);
EnsureAlloced(len + 1);
strcpy(m_data->data, text);
@ -371,7 +371,7 @@ inline str::str(const unsigned long long num)
char text[64];
size_t len;
sprintf(text, "%llu", num);
snprintf(text, sizeof(text), "%llu", num);
len = strlen(text);
EnsureAlloced(len + 1);
strcpy(m_data->data, text);

View file

@ -65,7 +65,7 @@ void TIKI_Message(const char *fmt, ...)
va_list va;
va_start(va, fmt);
vsprintf(msg, fmt, va);
Q_vsnprintf(msg, sizeof(msg), fmt, va);
va_end(va);
Skel_DPrintf(msg);
}
@ -81,7 +81,7 @@ void TIKI_Warning(const char *fmt, ...)
va_list va;
va_start(va, fmt);
vsprintf(msg, fmt, va);
Q_vsnprintf(msg, sizeof(msg), fmt, va);
va_end(va);
Skel_DPrintf(msg);
}
@ -97,7 +97,7 @@ void TIKI_Error(const char *fmt, ...)
va_list va;
va_start(va, fmt);
vsprintf(msg, fmt, va);
Q_vsnprintf(msg, sizeof(msg), fmt, va);
va_end(va);
Skel_DPrintf(msg);
}

View file

@ -394,8 +394,8 @@ void TikiScript::AddMacro( const char *name, const char *expansion )
}
else
{
strcpy( macros[ nummacros ].name, name );
strcpy( macros[ nummacros ].macro, expansion );
Q_strncpyz( macros[ nummacros ].name, name, sizeof( macros[ nummacros ].name ) );
Q_strncpyz( macros[ nummacros ].macro, expansion, sizeof( macros[ nummacros ].macro ) );
nummacros++;
}
@ -450,13 +450,13 @@ qboolean TikiScript::ProcessCommand( qboolean crossline )
}
else if( !stricmp( command, "path" ) )
{
strcpy( path, argument1 );
Q_strncpyz( path, argument1, sizeof( path ) );
len = strlen( path );
if( path[ len - 1 ] != '/' &&
path[ len - 1 ] != '\\' )
{
strcat( path, "/" );
Q_strcat( path, sizeof( path ), "/" );
}
SkipToEOL();
@ -790,7 +790,7 @@ const char *TikiScript::GetToken( qboolean crossline )
{
strcat( temptoken, macro_end + 1 );
}
strcpy( i->token, temptoken );
Q_strncpyz( i->token, temptoken, sizeof( i->token ) );
}
else
{
@ -808,7 +808,7 @@ const char *TikiScript::GetToken( qboolean crossline )
{
strcat( temptoken, macro_end + 1 );
}
strcpy( i->token, temptoken );
Q_strncpyz( i->token, temptoken, sizeof( i->token ) );
}
}
}
@ -1198,7 +1198,7 @@ int TikiScript::LinesInFile( void )
temp_tokenready = tokenready;
temp_script_p = script_p;
temp_line = line;
strcpy( temp_token, token );
Q_strncpyz( temp_token, token, sizeof( temp_token ) );
numentries = 0;
@ -1212,7 +1212,7 @@ int TikiScript::LinesInFile( void )
tokenready = temp_tokenready;
script_p = temp_script_p;
line = temp_line;
strcpy( token, temp_token );
Q_strncpyz( token, temp_token, sizeof( token ) );
return numentries;
}
@ -1307,7 +1307,7 @@ void TikiScript::MarkPos( void )
{
mark[ mark_pos ].mark_script_p = script_p;
mark[ mark_pos ].mark_tokenready = tokenready;
strcpy( mark[ mark_pos ].mark_token, token );
Q_strncpyz( mark[ mark_pos ].mark_token, token, sizeof(mark[ mark_pos ].mark_token));
mark_pos++;
}

View file

@ -929,7 +929,7 @@ image_t* R_CreateImage(
image->dynamicallyUpdated = dynamicallyUpdated;
image->force32bit = force32bit;
strcpy (image->imgName, name);
Q_strncpyz (image->imgName, name, sizeof(image->imgName));
image->width = width;
image->height = height;
@ -2491,7 +2491,7 @@ static void R_LoadImage(const char* name, byte** pic, int* width, int* height, q
if (scr_initialized)
{
sprintf(tempName, "n%s", name);
Com_sprintf(tempName, sizeof(tempName), "n%s", name);
UI_LoadResource(tempName);
}
}

View file

@ -219,7 +219,7 @@ static qhandle_t R_RegisterModelInternal( const char *name, qboolean bBeginTiki,
if( !stricmp( ptr, "spr" ) )
{
mod->d.sprite = SPR_RegisterSprite( name );
strcpy( mod->name, name );
Q_strncpyz( mod->name, name, sizeof( mod->name ) );
if( mod->d.sprite )
{
@ -230,7 +230,7 @@ static qhandle_t R_RegisterModelInternal( const char *name, qboolean bBeginTiki,
else if( !stricmp( ptr, "tik" ) )
{
mod->d.tiki = TIKI_RegisterTikiFlags( name, use );
strcpy( mod->name, name );
Q_strncpyz( mod->name, name, sizeof( mod->name ) );
if( mod->d.tiki )
{
@ -315,7 +315,7 @@ void R_ModelInit( void ) {
tr.numModels = 0;
mod = R_AllocModel();
strcpy( mod->name, "** BAD MODEL **" );
Q_strncpyz( mod->name, "** BAD MODEL **", sizeof( mod->name ) );
mod->type = MOD_BAD;
for (i = 0; i < sizeof(tr.skel_index) / sizeof(tr.skel_index[0]); i++) {
@ -533,7 +533,7 @@ int GetToolLodCutoff( skelHeaderGame_t *skelmodel, float lod_val ) {
if( lod_save->integer == 1 )
{
Cvar_Set( "lod_save", "0" );
strcpy( lodPath, GetModelPath( skelmodel ) );
Q_strncpyz( lodPath, GetModelPath( skelmodel ), sizeof( lodPath ) );
ext = strstr( lodPath, "skd" );
strcpy( ext, "lod" );
SaveLODFile( lodPath, LOD );

View file

@ -1256,7 +1256,7 @@ void R_Sphere_InitLights()
continue;
}
strcpy(s_sun.szFlareName, COM_Parse((char **)&ents));
Q_strncpyz(s_sun.szFlareName, COM_Parse((char **)&ents), sizeof(s_sun.szFlareName));
} else if (!strcmp(ret, "ambientlight")) {
if (bWorldProcessed) {
ri.Printf(PRINT_WARNING, "Multiple ambientlights defined in map\n");
@ -1279,7 +1279,7 @@ void R_Sphere_InitLights()
}
if (s_sun.exists && !s_sun.szFlareName[0]) {
strcpy(s_sun.szFlareName, "sun");
Q_strncpyz(s_sun.szFlareName, "sun", sizeof(s_sun.szFlareName));
}
}

View file

@ -81,9 +81,9 @@ void R_InitStaticModels(void)
AngleVectorsLeft(pSM->angles, pSM->axis[0], pSM->axis[1], pSM->axis[2]);
if (!strnicmp(pSM->model, "models", 6)) {
strcpy(szTemp, pSM->model);
Q_strncpyz(szTemp, pSM->model, sizeof(szTemp));
} else {
sprintf(szTemp, "models/%s", pSM->model);
Com_sprintf(szTemp, sizeof(szTemp), "models/%s", pSM->model);
}
FS_CanonicalFilename(szTemp);

View file

@ -262,7 +262,7 @@ void R_DrawDebugNumber( const vec3_t org, float number, float scale, float r, fl
VectorScale(right, scale, right);
if (precision > 0) {
sprintf(format, "%%.%df", precision);
Com_sprintf(format, sizeof(format), "%%.%df", precision);
text = va(format, number);
} else {
text = va("%d", (int)number);

View file

@ -1455,7 +1455,7 @@ void ScriptCompiler::CompileError(unsigned int sourcePos, const char *format, ..
va_list va;
va_start(va, format);
vsprintf(buffer, format, va);
Q_vsnprintf(buffer, sizeof(buffer), format, va);
va_end(va);
compileSuccess = false;

View file

@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
// scriptexception.cpp : Script Exception
#include "scriptexception.h"
#include "q_shared.h"
#include <cstdarg>
@ -50,7 +51,7 @@ ScriptException::ScriptException(const char *format, ...)
char data[4100];
va_start(va, format);
vsprintf(data, format, va);
Q_vsnprintf(data, sizeof(data), format, va);
va_end(va);
CreateException(data);
@ -67,7 +68,7 @@ void Error(const char *format, ...)
char data[4100];
va_start(va, format);
vsprintf(data, format, va);
Q_vsnprintf(data, sizeof(data), format, va);
va_end(va);
throw ScriptException((const char *)data);

View file

@ -417,7 +417,7 @@ void ScriptVM::error(const char *format, ...)
va_list va;
va_start(va, format);
vsprintf(buffer, format, va);
Q_vsnprintf(buffer, sizeof(buffer), format, va);
va_end(va);
gi.Printf("----------------------------------------------------------\n%s\n", buffer);

View file

@ -186,7 +186,7 @@ static void SV_Map_f( void ) {
}
else
{
strcpy( map, mapname );
Q_strncpyz( map, mapname, sizeof( map ) );
}
// make sure the level exists before trying to change, so that
@ -284,7 +284,7 @@ static void SV_GameMap_f( void ) {
map = Cmd_Argv( 1 );
Com_DPrintf( "SV_GameMap(%s)\n", map );
strcpy( svs.gameName, "current" );
Q_strncpyz( svs.gameName, "current", sizeof( svs.gameName ) );
Cvar_SaveGameRestart_f();
bTransition = sv.state == SS_GAME;
@ -1274,7 +1274,7 @@ static void SV_ConSay_f(void) {
return;
}
strcpy (text, "console: ");
Q_strncpyz (text, "console: ", sizeof(text));
p = Cmd_Args();
if ( *p == '"' ) {
@ -1314,7 +1314,7 @@ static void SV_ConTell_f(void) {
return;
}
strcpy (text, "(private) console: ");
Q_strncpyz(text, "(private) console: ", sizeof(text));
p = Cmd_ArgsFrom(2);
if ( *p == '"' ) {
@ -1380,7 +1380,7 @@ static void SV_ConSayto_f(void) {
return;
}
strcpy (text, "(private) console: ");
Q_strncpyz(text, "(private) console: ", sizeof(text));
p = Cmd_ArgsFrom(2);
if ( *p == '"' ) {
@ -1584,8 +1584,8 @@ static void SV_TIKI_f( void ) {
if(TIKI_RegisterModel(fname)==0)
{
char tmp[128];
strcpy(tmp,"models/");
strcat(tmp,fname);
Q_strncpyz(tmp,"models/",sizeof(tmp));
Q_strcat(tmp,sizeof(tmp),fname);
TIKI_RegisterModel(tmp);
}
}
@ -1606,8 +1606,8 @@ static void SV_TIKI_DumpBones_f( void ) {
if(tiki==0)
{
char tmp[128];
strcpy(tmp,"models/");
strcat(tmp,fname);
Q_strncpyz(tmp,"models/",sizeof(tmp));
Q_strcat(tmp,sizeof(tmp),fname);
tiki = TIKI_RegisterModel(tmp);
if(!tiki)
return;
@ -1768,7 +1768,7 @@ SV_HudDrawShader
void SV_HudDrawShader( int iInfo, char *name )
{
#ifndef DEDICATED
strcpy( cls.HudDrawElements[ iInfo ].shaderName, name );
Q_strncpyz( cls.HudDrawElements[ iInfo ].shaderName, name, sizeof(cls.HudDrawElements[ iInfo ].shaderName) );
cls.HudDrawElements[ iInfo ].string[ 0 ] = 0;
cls.HudDrawElements[ iInfo ].pFont = NULL;
cls.HudDrawElements[ iInfo ].fontName[ 0 ] = 0;
@ -1852,7 +1852,7 @@ void SV_HudDrawString( int iInfo, const char *string )
{
#ifndef DEDICATED
cls.HudDrawElements[ iInfo ].hShader = 0;
strcpy( cls.HudDrawElements[ iInfo ].string, string );
Q_strncpyz( cls.HudDrawElements[ iInfo ].string, string, sizeof(cls.HudDrawElements[iInfo].string) );
#endif
}
@ -1864,7 +1864,7 @@ SV_HudDrawFont
void SV_HudDrawFont( int iInfo, const char *name )
{
#ifndef DEDICATED
strcpy( cls.HudDrawElements[ iInfo ].fontName, name );
Q_strncpyz( cls.HudDrawElements[ iInfo ].fontName, name, sizeof(cls.HudDrawElements[iInfo].fontName) );
cls.HudDrawElements[ iInfo ].hShader = 0;
cls.HudDrawElements[ iInfo ].shaderName[ 0 ] = 0;
@ -2073,7 +2073,7 @@ qboolean SV_ArchiveServerFile( qboolean loading, qboolean autosave )
if( strstr( name, "quick.ssv" ) ) {
Com_sprintf( save.comment, sizeof( save.comment ), "QuickSave - %s", comment );
} else {
strcpy( save.comment, comment );
Q_strncpyz( save.comment, comment, sizeof( save.comment ) );
}
SV_SetConfigstring( CS_SAVENAME, "" );
@ -2083,8 +2083,8 @@ qboolean SV_ArchiveServerFile( qboolean loading, qboolean autosave )
save.flags = 0;
save.time = aclock;
strncpy( save.mapName, svs.mapName, sizeof( save.mapName ) );
strncpy( save.saveName, svs.gameName, sizeof( save.saveName ) );
Q_strncpyz( save.mapName, svs.mapName, sizeof( save.mapName ) );
Q_strncpyz( save.saveName, svs.gameName, sizeof( save.saveName ) );
save.mapTime = svs.time - svs.startTime;
name = S_GetMusicFilename();
@ -2127,10 +2127,10 @@ qboolean SV_ArchiveServerFile( qboolean loading, qboolean autosave )
S_StopAllSounds2( qtrue );
S_Load( f );
strncpy( svs.mapName, save.mapName, sizeof( svs.mapName ) );
Q_strncpyz( svs.mapName, save.mapName, sizeof( svs.mapName ) );
svs.mapTime = save.mapTime;
svs.areabits_warning_time = 0;
strcpy( svs.tm_filename, save.tm_filename );
Q_strncpyz( svs.tm_filename, save.tm_filename, sizeof( svs.tm_filename ) );
svs.tm_loopcount = save.tm_loopcount;
svs.tm_offset = save.tm_offset;
FS_FCloseFile( f );
@ -2198,7 +2198,7 @@ void SV_Loadgame_f( void )
Com_Printf( "Bad savedir.\n" );
}
strcpy( svs.gameName, name );
Q_strncpyz( svs.gameName, name, sizeof( svs.gameName ) );
archive_name = Com_GetArchiveFileName( name, "sav" );
Cvar_SaveGameRestart_f();
@ -2352,11 +2352,11 @@ void SV_SaveGame( const char *gamename, qboolean autosave )
if( gamename )
{
strcpy( name, gamename );
Q_strncpyz( name, gamename, sizeof( name ) );
}
else
{
strcpy( mname, svs.mapName );
Q_strncpyz( mname, svs.mapName, sizeof( mname ) );
for( ptr = strchr( mname, '/' ); ptr != NULL; ptr = strchr( mname, '/' ) )
{
*ptr = '_';
@ -2377,7 +2377,7 @@ void SV_SaveGame( const char *gamename, qboolean autosave )
Com_Printf( "...\n" );
}
strcpy( svs.gameName, name );
Q_strncpyz( svs.gameName, name, sizeof( svs.gameName ) );
if (!SV_ArchiveLevelFile(qfalse, autosave)) {
if (cls.savedCgameState) {
@ -2390,7 +2390,7 @@ void SV_SaveGame( const char *gamename, qboolean autosave )
Com_Printf( "Done.\n" );
strcpy( svs.gameName, "current" );
Q_strncpyz( svs.gameName, "current", sizeof( svs.gameName ) );
#endif
}
@ -2418,7 +2418,7 @@ void SV_Savegame_f( void )
return;
}
strcpy( savegame_name, s );
Q_strncpyz( savegame_name, s, sizeof( savegame_name ) );
}
else
{

View file

@ -1410,7 +1410,7 @@ void PF_centerprintf( gentity_t *ent, const char *fmt, ... )
}
va_start( va, fmt );
vsprintf( msg, fmt, va );
Q_vsnprintf( msg, sizeof( msg ), fmt, va );
va_end( va );
if( strlen( msg ) > 256 ) {
@ -1436,7 +1436,7 @@ void PF_locationprintf( gentity_t *ent, int x, int y, const char *fmt, ... )
}
va_start( va, fmt );
vsprintf( msg, fmt, va );
Q_vsnprintf( msg, sizeof( msg ), fmt, va );
va_end( va );
if( strlen( msg ) > 256 ) {

View file

@ -212,8 +212,8 @@ int SV_SoundIndex( const char *name, qboolean streamed )
{
char buf[ 1024 ];
strcpy( buf, name );
strcat( buf, va( "%d", streamed ) );
Q_strncpyz( buf, name, sizeof(buf) );
Q_strcat( buf, sizeof(buf), va( "%d", streamed ) );
return SV_FindIndex( buf, CS_SOUNDS, MAX_SOUNDS, qtrue );
}
@ -602,7 +602,7 @@ void SV_SpawnServer( const char *server, qboolean loadgame, qboolean restart, qb
}
else
{
strcpy( mapname, server );
Q_strncpyz( mapname, server, sizeof(mapname) );
}
strncpy( svs.mapName, mapname, sizeof( svs.mapName ) );
@ -927,7 +927,7 @@ void SV_SpawnServer( const char *server, qboolean loadgame, qboolean restart, qb
}
}
strcpy( svs.gameName, "current" );
Q_strncpyz(svs.gameName, "current", sizeof(svs.gameName) );
iEnd = Sys_Milliseconds();
Com_Printf( "------ Server Initialization Complete ------ %5.2f seconds\n", ( float )iEnd / 1000.0f );
@ -1072,7 +1072,7 @@ void SV_Init (void)
#endif
sv_banFile = Cvar_Get("sv_banFile", "serverbans.dat", CVAR_ARCHIVE);
strcpy( svs.gameName, "current" );
Q_strncpyz( svs.gameName, "current", sizeof(svs.gameName) );
// dday vars
Cvar_Get( "g_ddayfodderguys", "0", CVAR_ARCHIVE );

View file

@ -493,7 +493,7 @@ void SVC_Status( netadr_t from ) {
if(strlen(Cmd_Argv(1)) > 128)
return;
strcpy( infostring, Cvar_InfoString( CVAR_SERVERINFO ) );
Q_strncpyz( infostring, Cvar_InfoString( CVAR_SERVERINFO ), sizeof( infostring ) );
// echo back the parameter to status. so master servers can use it as a challenge
// to prevent timed spoofed reply packets that add ghost servers
@ -514,7 +514,7 @@ void SVC_Status( netadr_t from ) {
if (statusLength + playerLength >= sizeof(status) ) {
break; // can't hold any more
}
strcpy (status + statusLength, player);
Q_strncpyz (status + statusLength, player, sizeof(status) - statusLength);
statusLength += playerLength;
}
}

View file

@ -160,7 +160,7 @@ void SV_ClearWorld( void ) {
num = CM_NumInlineModels();
for( i = 1; i < num; i++ )
{
sprintf( name, "*%i", i );
Com_sprintf( name, sizeof( name ), "*%i", i );
SV_ModelIndex( name );
}
}

View file

@ -32,7 +32,7 @@ void ChannelNameTable::CopyChannel(ChannelName_t *dest, const ChannelName_t *sou
void ChannelNameTable::SetChannelName(ChannelName_t *channel, const char *newName)
{
strcpy(channel->name, newName);
Q_strncpyz(channel->name, newName, sizeof(channel->name));
}
ChannelNameTable::ChannelNameTable()

View file

@ -32,7 +32,7 @@ void Skel_DPrintf(const char *fmt, ...)
va_list va;
va_start(va, fmt);
vsprintf(msg, fmt, va);
Q_vsnprintf(msg, sizeof(msg), fmt, va);
va_end(va);
Com_DPrintf("%s", msg);

View file

@ -31,7 +31,7 @@ void SKEL_Message(const char *fmt, ...)
va_list va;
va_start(va, fmt);
vsprintf(msg, fmt, va);
Q_vsnprintf(msg, sizeof(msg), fmt, va);
va_end(va);
Skel_DPrintf(msg);
}
@ -42,7 +42,7 @@ void SKEL_Warning(const char *fmt, ...)
va_list va;
va_start(va, fmt);
vsprintf(msg, fmt, va);
Q_vsnprintf(msg, sizeof(msg), fmt, va);
va_end(va);
Skel_DPrintf(msg);
}
@ -53,7 +53,7 @@ void SKEL_Error(const char *fmt, ...)
va_list va;
va_start(va, fmt);
vsprintf(msg, fmt, va);
Q_vsnprintf(msg, sizeof(msg), fmt, va);
va_end(va);
Skel_DPrintf(msg);
}

View file

@ -31,7 +31,7 @@ void Sys_LaunchAutoupdater(int argc, char **argv)
memset(&procinfo, '\0', sizeof (procinfo));
memset(&startinfo, '\0', sizeof (startinfo));
startinfo.cb = sizeof (startinfo);
sprintf(cmdline, "" AUTOUPDATER_BIN " --waitpid %u", (unsigned int) GetCurrentProcessId());
Com_sprintf(cmdline, sizeof(cmdline), "" AUTOUPDATER_BIN " --waitpid %u", (unsigned int) GetCurrentProcessId());
if (CreateProcessA(AUTOUPDATER_BIN, cmdline, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startinfo, &procinfo))
{

View file

@ -75,7 +75,7 @@ cLocalization::cLocalization()
size_t iBasePos;
ppszFiles = FS_ListFilteredFiles( "global", "txt", "localization*.txt", qfalse, &iFileCount, qtrue );
strcpy( szFilename, "global/" );
Q_strncpyz( szFilename, "global/", sizeof( szFilename ) );
memset( szFilename + 8, 0, sizeof( szFilename ) - 8 );
iBasePos = strlen( szFilename );
@ -83,7 +83,7 @@ cLocalization::cLocalization()
qsort( ppszFiles, iFileCount, sizeof( char * ), compare_strings );
for( i = 0; i < iFileCount; i++ )
{
strcpy( szFilename + iBasePos, ppszFiles[ i ] );
Q_strncpyz( szFilename + iBasePos, ppszFiles[ i ], sizeof( szFilename ) - iBasePos );
Com_Printf( "--- Localization: reading file %s\n", szFilename );
LoadFile( szFilename );
}

View file

@ -102,7 +102,7 @@ dtikianim_t *TIKI_RegisterTikiAnimFlags(const char *path, qboolean use)
dtikianim_t *tiki;
char filename[1024];
strcpy(filename, path);
Q_strncpyz(filename, path, sizeof(filename));
FS_CanonicalFilename(filename);
if (tikianimcache) {
@ -182,9 +182,9 @@ dtiki_t *TIKI_RegisterTikiFlags(const char *path, qboolean use)
strcat(full_filename, "|");
}
strcpy(filename, name);
Q_strncpyz(filename, name, sizeof(filename));
FS_CanonicalFilename(filename);
strcat(full_filename, filename);
Q_strcat(full_filename, sizeof(full_filename), filename);
if (!tikicache) {
tikicache = new con_map<pchar, dtiki_t *>;

View file

@ -256,14 +256,14 @@ dtikianim_t *TIKI_LoadTikiAnim(const char *path)
TIKI_AddDefaultIdleAnim(&loaddef);
if (loaddef.numanims) {
sprintf(tempName, "a%s", path);
Com_sprintf(tempName, sizeof(tempName), "a%s", path);
UI_LoadResource(tempName);
tiki = TIKI_FillTIKIStructureSkel(&loaddef);
if (tiki) {
sprintf(tempName, "b%s", path);
Com_sprintf(tempName, sizeof(tempName), "b%s", path);
UI_LoadResource(tempName);
sprintf(tempName, "c%s", path);
Com_sprintf(tempName, sizeof(tempName), "c%s", path);
UI_LoadResource(tempName);
VectorSubtract(tiki->maxs, tiki->mins, tempVec);
@ -273,7 +273,7 @@ dtikianim_t *TIKI_LoadTikiAnim(const char *path)
}
TIKI_FreeStorage(&loaddef);
sprintf(tempName, "d%s", path);
Com_sprintf(tempName, sizeof(tempName), "d%s", path);
UI_LoadResource(tempName);
} else {
TIKI_FreeStorage(&loaddef);
@ -539,8 +539,8 @@ skelAnimDataGameHeader_t *SkeletorCacheFileCallback(const char *path)
Com_DPrintf("Skeletor CacheAnimSkel: %s: File extension unknown. Attempting to open as skc file\n", path);
}
strcpy(npath, "newanim/");
strcat(npath, path);
Q_strncpyz(npath, "newanim/", sizeof(npath));
Q_strcat(npath, sizeof(npath), path);
iBuffLength = TIKI_ReadFileEx(npath, (void **)&buffer, qtrue);
if (iBuffLength > 0) {
@ -714,7 +714,7 @@ bool SkeletorCacheLoadData(const char *path, bool precache, int newIndex)
m_cachedDataLookup[newIndex] = lookup;
m_cachedData[lookup].lookup = newIndex;
m_cachedData[lookup].data = data;
strcpy(m_cachedData[lookup].path, path);
Q_strncpyz(m_cachedData[lookup].path, path, sizeof(m_cachedData[lookup].path));
m_cachedData[lookup].numusers = 0;
m_numInCache++;
@ -985,7 +985,7 @@ dtikianim_t *TIKI_InitTiki(dloaddef_t *ld, size_t defsize)
ptr += sizeof(dtikianimdef_t);
panim->animdefs[i] = panimdef;
panim->m_aliases[i] = alias_index;
strcpy(panimdef->alias, anim->alias);
Q_strncpyz(panimdef->alias, anim->alias, sizeof(panimdef->alias));
panimdef->weight = anim->weight;
panimdef->flags = anim->flags;
@ -1093,7 +1093,7 @@ dtikianim_t *TIKI_InitTiki(dloaddef_t *ld, size_t defsize)
memcpy(panim->headskins, ld->headskins, size);
ptr += size;
sprintf(tempName, "h%s", ld->path);
Com_sprintf(tempName, sizeof(tempName), "h%s", ld->path);
UI_LoadResource(tempName);
if (low_anim_memory && (!low_anim_memory->integer || !tiki_loading)) {

View file

@ -32,7 +32,7 @@ void TIKI_DPrintf(const char *fmt, ...)
va_list va;
va_start(va, fmt);
vsprintf(msg, fmt, va);
Q_vsnprintf(msg, sizeof(msg), fmt, va);
va_end(va);
Com_DPrintf("%s", msg);

View file

@ -150,7 +150,7 @@ void TIKI_ParseFrameCommands(dloaddef_t *ld, dloadframecmd_t **cmdlist, int maxc
cmds->frame_num = framenum;
if (ld->tikiFile.currentScript) {
sprintf(cmds->location, "%s, line: %d", ld->tikiFile.Filename(), ld->tikiFile.GetLineNumber());
Com_sprintf(cmds->location, sizeof(cmds->location), "%s, line: %d", ld->tikiFile.Filename(), ld->tikiFile.GetLineNumber());
}
while (ld->tikiFile.TokenAvailable(false)) {
@ -468,13 +468,14 @@ void TIKI_ParseAnimations(dloaddef_t *ld)
anim->alias = (char *)TIKI_CopyString(token);
token = ld->tikiFile.GetToken(false);
strcpy(anim->name, TikiScript::currentScript->path);
strcat(anim->name, token);
Q_strncpyz(anim->name, TikiScript::currentScript->path, sizeof(anim->name));
Q_strcat(anim->name, sizeof(anim->name), token);
anim->location[0] = 0;
if (ld->tikiFile.currentScript) {
sprintf(
Com_sprintf(
anim->location,
sizeof(anim->location),
"%s, line: %d",
ld->tikiFile.currentScript->Filename(),
ld->tikiFile.currentScript->GetLineNumber()
@ -890,7 +891,7 @@ qboolean TIKI_LoadSetupCase(
loadsurfaces[currentSurface].flags = 0;
(*numSurfacesSetUp)++;
}
strcpy(loadsurfaces[currentSurface].name, name);
Q_strncpyz(loadsurfaces[currentSurface].name, name, sizeof(loadsurfaces[currentSurface].name));
break;
case SETUP_FLAGS:
flags = MSG_ReadLong(msg);
@ -1031,17 +1032,17 @@ qboolean TIKI_ParseSetup(dloaddef_t *ld)
WriteLodBias(ld, lod_bias);
} else if (!Q_stricmp(token, "skelmodel")) {
token = ld->tikiFile.GetToken(false);
strcpy(name, ld->tikiFile.currentScript->path);
strcat(name, token);
Q_strncpyz(name, ld->tikiFile.currentScript->path, sizeof(name));
Q_strcat(name, sizeof(name), token);
WriteSkelmodel(ld, name);
} else if (!Q_stricmp(token, "path")) {
token = ld->tikiFile.GetToken(false);
strcpy(ld->tikiFile.currentScript->path, token);
Q_strncpyz(ld->tikiFile.currentScript->path, token, sizeof(name));
length = strlen(ld->tikiFile.currentScript->path);
token = ld->tikiFile.currentScript->path + length - 1;
if (*token != '/' && *token != '\\') {
strcat(ld->tikiFile.currentScript->path, "/");
Q_strcat(ld->tikiFile.currentScript->path, sizeof(ld->tikiFile.currentScript->path), "/");
}
} else if (!Q_stricmp(token, "orgin")) {
tmpVec[0] = ld->tikiFile.GetFloat(false);
@ -1071,8 +1072,8 @@ qboolean TIKI_ParseSetup(dloaddef_t *ld)
} else if (!Q_stricmp(token, "shader")) {
token = ld->tikiFile.GetToken(false);
if (strstr(token, ".")) {
strcpy(name, ld->tikiFile.currentScript->path);
strcat(name, token);
Q_strncpyz(name, ld->tikiFile.currentScript->path, sizeof(name));
Q_strcat(name, sizeof(name), token);
WriteShader(ld, name);
} else {
WriteShader(ld, token);

View file

@ -739,7 +739,7 @@ void GetLODFile(skelcache_t *cache)
return;
}
strcpy(pathLOD, cache->path);
Q_strncpyz(pathLOD, cache->path, sizeof(pathLOD));
ext = strstr(pathLOD, "skd");
strcpy(ext, "lod");
@ -1069,7 +1069,7 @@ int TIKI_RegisterSkel(const char *path, dtiki_t *tiki)
}
}
sprintf(tempName, "l%s", path);
Com_sprintf(tempName, sizeof(tempName), "l%s", path);
UI_LoadResource(tempName);
return cache - skelcache;

View file

@ -101,7 +101,7 @@ void UI_SetCvarInt( const char *cvar, int value )
{
char s[ 16 ];
sprintf( s, "%d", value );
Com_sprintf( s, sizeof( s ), "%d", value );
uii.Cvar_Set( cvar, s );
}
@ -109,7 +109,7 @@ void UI_SetCvarFloat( const char *cvar, float value )
{
char s[ 16 ];
sprintf( s, "%f", value );
Com_sprintf( s, sizeof( s ), "%f", value );
uii.Cvar_Set( cvar, s );
}