Lets not do the last two commits just before 5.11

Revert "change several strcat calls to Q_strlcat calls"
This reverts commit ab879f1bc7.

Revert "change (v)sprintf calls to (v)snprintf calls"
This reverts commit b46e210d76.
This commit is contained in:
svdijk 2013-05-18 18:59:12 +02:00
parent ab879f1bc7
commit 6472514c8f
25 changed files with 66 additions and 61 deletions

View file

@ -346,9 +346,9 @@ VID_CheckChanges(void)
cls.disable_screen = true; cls.disable_screen = true;
#ifdef _WIN32 #ifdef _WIN32
snprintf(name, sizeof(name), "ref_%s.dll", vid_ref->string); sprintf(name, "ref_%s.dll", vid_ref->string);
#else #else
snprintf(name, sizeof(name), "ref_%s.so", vid_ref->string); sprintf(name, "ref_%s.so", vid_ref->string);
#endif #endif
if (!VID_LoadRefresh(name)) if (!VID_LoadRefresh(name))

View file

@ -839,7 +839,7 @@ NET_Socket(char *net_interface, int port, netsrc_t type, int family)
} }
else else
{ {
snprintf(Buf, sizeof(Buf), "%5d", port); sprintf(Buf, "%5d", port);
Service = Buf; Service = Buf;
} }

View file

@ -177,7 +177,7 @@ Sys_FindFirst(char *path, unsigned musthave, unsigned canhave)
{ {
if (CompareAttributes(findbase, d->d_name, musthave, canhave)) if (CompareAttributes(findbase, d->d_name, musthave, canhave))
{ {
snprintf(findpath, sizeof(findpath), "%s/%s", findbase, d->d_name); sprintf(findpath, "%s/%s", findbase, d->d_name);
return findpath; return findpath;
} }
} }
@ -202,7 +202,7 @@ Sys_FindNext(unsigned musthave, unsigned canhave)
{ {
if (CompareAttributes(findbase, d->d_name, musthave, canhave)) if (CompareAttributes(findbase, d->d_name, musthave, canhave))
{ {
snprintf(findpath, sizeof(findpath), "%s/%s", findbase, d->d_name); sprintf(findpath, "%s/%s", findbase, d->d_name);
return findpath; return findpath;
} }
} }

View file

@ -834,7 +834,7 @@ NET_IPSocket(char *net_interface, int port, netsrc_t type, int family)
} }
else else
{ {
snprintf(Buf, sizeof(Buf), "%5d", port); sprintf(Buf, "%5d", port);
Service = Buf; Service = Buf;
} }

View file

@ -80,7 +80,7 @@ Sys_Error(char *error, ...)
Qcommon_Shutdown(); Qcommon_Shutdown();
va_start(argptr, error); va_start(argptr, error);
vsnprintf(text, sizeof(text), error, argptr); vsprintf(text, error, argptr);
va_end(argptr); va_end(argptr);
#ifndef DEDICATED_ONLY #ifndef DEDICATED_ONLY

View file

@ -449,7 +449,7 @@ Con_CenteredPrint(char *text)
memset(buffer, ' ', l); memset(buffer, ' ', l);
strcpy(buffer + l, text); strcpy(buffer + l, text);
Q_strlcat(buffer, "\n", sizeof(buffer)); strcat(buffer, "\n");
Con_Print(buffer); Con_Print(buffer);
} }
@ -704,14 +704,14 @@ Con_DrawConsole(float frac)
y = x - i - 11; y = x - i - 11;
memcpy(dlbar, text, i); memcpy(dlbar, text, i);
dlbar[i] = 0; dlbar[i] = 0;
Q_strlcat(dlbar, "...", sizeof(dlbar)); strcat(dlbar, "...");
} }
else else
{ {
strcpy(dlbar, text); strcpy(dlbar, text);
} }
Q_strlcat(dlbar, ": ", sizeof(dlbar)); strcat(dlbar, ": ");
i = strlen(dlbar); i = strlen(dlbar);
dlbar[i++] = '\x80'; dlbar[i++] = '\x80';
@ -742,7 +742,7 @@ Con_DrawConsole(float frac)
dlbar[i++] = '\x82'; dlbar[i++] = '\x82';
dlbar[i] = 0; dlbar[i] = 0;
snprintf(dlbar + i, sizeof(dlbar) - i, " %02d%%", cls.downloadpercent); sprintf(dlbar + strlen(dlbar), " %02d%%", cls.downloadpercent);
/* draw it */ /* draw it */
y = con.vislines - 12; y = con.vislines - 12;

View file

@ -399,7 +399,7 @@ CL_RequestNextDownload(void)
{ {
char fn[MAX_OSPATH]; char fn[MAX_OSPATH];
snprintf(fn, sizeof(fn), "textures/%s.wal", sprintf(fn, "textures/%s.wal",
map_surfaces[precache_tex++].rname); map_surfaces[precache_tex++].rname);
if (!CL_CheckOrDownloadFile(fn)) if (!CL_CheckOrDownloadFile(fn))
@ -469,7 +469,7 @@ CL_CheckOrDownloadFile(char *filename)
to the real name when done, so if interrupted to the real name when done, so if interrupted
a runt file wont be left */ a runt file wont be left */
COM_StripExtension(cls.downloadname, cls.downloadtempname); COM_StripExtension(cls.downloadname, cls.downloadtempname);
Q_strlcat(cls.downloadtempname, ".tmp", sizeof(cls.downloadtempname)); strcat(cls.downloadtempname, ".tmp");
/* check to see if we already have a tmp for this /* check to see if we already have a tmp for this
file, if so, try to resume and open the file if file, if so, try to resume and open the file if
@ -540,7 +540,7 @@ CL_Download_f(void)
to the real name when done, so if interrupted to the real name when done, so if interrupted
a runt file wont be left */ a runt file wont be left */
COM_StripExtension(cls.downloadname, cls.downloadtempname); COM_StripExtension(cls.downloadname, cls.downloadtempname);
Q_strlcat(cls.downloadtempname, ".tmp", sizeof(cls.downloadtempname)); strcat(cls.downloadtempname, ".tmp");
MSG_WriteByte(&cls.netchan.message, clc_stringcmd); MSG_WriteByte(&cls.netchan.message, clc_stringcmd);
MSG_WriteString(&cls.netchan.message, va("download %s", cls.downloadname)); MSG_WriteString(&cls.netchan.message, va("download %s", cls.downloadname));

View file

@ -743,11 +743,11 @@ Key_Bind_f(void)
for (i = 2; i < c; i++) for (i = 2; i < c; i++)
{ {
Q_strlcat(cmd, Cmd_Argv(i), sizeof(cmd)); strcat(cmd, Cmd_Argv(i));
if (i != (c - 1)) if (i != (c - 1))
{ {
Q_strlcat(cmd, " ", sizeof(cmd)); strcat(cmd, " ");
} }
} }

View file

@ -277,12 +277,12 @@ CL_Setenv_f(void)
int i; int i;
strcpy(buffer, Cmd_Argv(1)); strcpy(buffer, Cmd_Argv(1));
Q_strlcat(buffer, "=", sizeof(buffer)); strcat(buffer, "=");
for (i = 2; i < argc; i++) for (i = 2; i < argc; i++)
{ {
Q_strlcat(buffer, Cmd_Argv(i), sizeof(buffer)); strcat(buffer, Cmd_Argv(i));
Q_strlcat(buffer, " ", sizeof(buffer)); strcat(buffer, " ");
} }
putenv(buffer); putenv(buffer);

View file

@ -247,15 +247,15 @@ CL_Rcon_f(void)
NET_Config(true); /* allow remote */ NET_Config(true); /* allow remote */
Q_strlcat(message, "rcon ", sizeof(message)); strcat(message, "rcon ");
Q_strlcat(message, rcon_client_password->string, sizeof(message)); strcat(message, rcon_client_password->string);
Q_strlcat(message, " ", sizeof(message)); strcat(message, " ");
for (i = 1; i < Cmd_Argc(); i++) for (i = 1; i < Cmd_Argc(); i++)
{ {
Q_strlcat(message, Cmd_Argv(i), sizeof(message)); strcat(message, Cmd_Argv(i));
Q_strlcat(message, " ", sizeof(message)); strcat(message, " ");
} }
if (cls.state >= ca_connected) if (cls.state >= ca_connected)

View file

@ -1184,7 +1184,7 @@ SCR_ExecuteLayoutString(char *s)
ping = 999; ping = 999;
} }
snprintf(block, sizeof(block), "%3d %3d %-12.12s", score, ping, ci->name); sprintf(block, "%3d %3d %-12.12s", score, ping, ci->name);
if (value == cl.playernum) if (value == cl.playernum)
{ {
@ -1508,7 +1508,7 @@ SCR_UpdateScreen(void)
if (cl_drawfps->value) if (cl_drawfps->value)
{ {
char s[8]; char s[8];
snprintf(s, sizeof(s), "%3.0ffps", 1 / cls.frametime); sprintf(s, "%3.0ffps", 1 / cls.frametime);
DrawString(viddef.width - 64, 0, s); DrawString(viddef.width - 64, 0, s);
} }

View file

@ -549,7 +549,7 @@ M_Main_Draw(void)
} }
strcpy(litname, names[m_main_cursor]); strcpy(litname, names[m_main_cursor]);
Q_strlcat(litname, "_sel", sizeof(litname)); strcat(litname, "_sel");
re.DrawPic(xoffset, ystart + m_main_cursor * 40 + 13, litname); re.DrawPic(xoffset, ystart + m_main_cursor * 40 + 13, litname);
M_DrawCursor(xoffset - 25, ystart + m_main_cursor * 40 + 11, M_DrawCursor(xoffset - 25, ystart + m_main_cursor * 40 + 11,
@ -3784,7 +3784,7 @@ IconOfSkinExists(char *skin, char **pcxfiles, int npcxfiles)
strcpy(scratch, skin); strcpy(scratch, skin);
*strrchr(scratch, '.') = 0; *strrchr(scratch, '.') = 0;
Q_strlcat(scratch, "_i.pcx", sizeof(scratch)); strcat(scratch, "_i.pcx");
for (i = 0; i < npcxfiles; i++) for (i = 0; i < npcxfiles; i++)
{ {
@ -3862,7 +3862,7 @@ PlayerConfig_ScanDirectories(void)
/* verify the existence of tris.md2 */ /* verify the existence of tris.md2 */
strcpy(scratch, dirnames[i]); strcpy(scratch, dirnames[i]);
Q_strlcat(scratch, "/tris.md2", sizeof(scratch)); strcat(scratch, "/tris.md2");
if (!Sys_FindFirst(scratch, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM)) if (!Sys_FindFirst(scratch, 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM))
{ {
@ -3876,7 +3876,7 @@ PlayerConfig_ScanDirectories(void)
/* verify the existence of at least one pcx skin */ /* verify the existence of at least one pcx skin */
strcpy(scratch, dirnames[i]); strcpy(scratch, dirnames[i]);
Q_strlcat(scratch, "/*.pcx", sizeof(scratch)); strcat(scratch, "/*.pcx");
pcxnames = FS_ListFiles(scratch, &npcxfiles, pcxnames = FS_ListFiles(scratch, &npcxfiles,
0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM); 0, SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM);

View file

@ -89,7 +89,7 @@ Com_Printf(char *fmt, ...)
*rd_buffer = 0; *rd_buffer = 0;
} }
Q_strlcat(rd_buffer, msg, rd_buffersize); strcat(rd_buffer, msg);
return; return;
} }

View file

@ -460,15 +460,15 @@ Cmd_Alias_f(void)
for (i = 2; i < c; i++) for (i = 2; i < c; i++)
{ {
Q_strlcat(cmd, Cmd_Argv(i), sizeof(cmd)); strcat(cmd, Cmd_Argv(i));
if (i != (c - 1)) if (i != (c - 1))
{ {
Q_strlcat(cmd, " ", sizeof(cmd)); strcat(cmd, " ");
} }
} }
Q_strlcat(cmd, "\n", sizeof(cmd)); strcat(cmd, "\n");
a->value = CopyString(cmd); a->value = CopyString(cmd);
} }

View file

@ -1100,16 +1100,22 @@ Com_sprintf(char *dest, int size, char *fmt, ...)
{ {
int len; int len;
va_list argptr; va_list argptr;
static char bigbuffer[0x10000];
va_start(argptr, fmt); va_start(argptr, fmt);
len = vsnprintf(dest, size, fmt, argptr); len = vsnprintf(bigbuffer, 0x10000, fmt, argptr);
va_end(argptr); va_end(argptr);
if (len >= size) if ((len >= size) || (len == size))
{ {
Com_Printf("Com_sprintf: overflow\n"); Com_Printf("Com_sprintf: overflow\n");
dest = NULL;
return; return;
} }
bigbuffer[size - 1] = '\0';
strcpy(dest, bigbuffer);
} }
char * char *

View file

@ -1096,9 +1096,9 @@ Cmd_Say_f(edict_t *ent, qboolean team, qboolean arg0)
if (arg0) if (arg0)
{ {
Q_strlcat(text, gi.argv(0), sizeof(text)); strcat(text, gi.argv(0));
Q_strlcat(text, " ", sizeof(text)); strcat(text, " ");
Q_strlcat(text, gi.args(), sizeof(text)); strcat(text, gi.args());
} }
else else
{ {
@ -1110,7 +1110,7 @@ Cmd_Say_f(edict_t *ent, qboolean team, qboolean arg0)
p[strlen(p) - 1] = 0; p[strlen(p) - 1] = 0;
} }
Q_strlcat(text, p, sizeof(text)); strcat(text, p);
} }
/* don't let text be too long for malicious reasons */ /* don't let text be too long for malicious reasons */
@ -1119,7 +1119,7 @@ Cmd_Say_f(edict_t *ent, qboolean team, qboolean arg0)
text[150] = 0; text[150] = 0;
} }
Q_strlcat(text, "\n", sizeof(text)); strcat(text, "\n");
if (flood_msgs->value) if (flood_msgs->value)
{ {
@ -1218,7 +1218,7 @@ Cmd_PlayerList_f(edict_t *ent)
if (strlen(text) + strlen(st) > sizeof(text) - 50) if (strlen(text) + strlen(st) > sizeof(text) - 50)
{ {
strcat(text, "And more...\n"); sprintf(text + strlen(text), "And more...\n");
gi.cprintf(ent, PRINT_HIGH, "%s", text); gi.cprintf(ent, PRINT_HIGH, "%s", text);
return; return;
} }

View file

@ -156,7 +156,7 @@ Sys_Error(char *error, ...)
char text[1024]; char text[1024];
va_start(argptr, error); va_start(argptr, error);
vsnprintf(text, sizeof(text), error, argptr); vsprintf(text, error, argptr);
va_end(argptr); va_end(argptr);
gi.error(ERR_FATAL, "%s", text); gi.error(ERR_FATAL, "%s", text);
@ -169,7 +169,7 @@ Com_Printf(char *msg, ...)
char text[1024]; char text[1024];
va_start(argptr, msg); va_start(argptr, msg);
vsnprintf(text, sizeof(text), msg, argptr); vsprintf(text, msg, argptr);
va_end(argptr); va_end(argptr);
gi.dprintf("%s", text); gi.dprintf("%s", text);

View file

@ -284,11 +284,11 @@ SVCmd_WriteIP_f(void)
if (!*game->string) if (!*game->string)
{ {
snprintf(name, sizeof(name), "%s/listip.cfg", GAMEVERSION); sprintf(name, "%s/listip.cfg", GAMEVERSION);
} }
else else
{ {
snprintf(name, sizeof(name), "%s/listip.cfg", game->string); sprintf(name, "%s/listip.cfg", game->string);
} }
gi.cprintf(NULL, PRINT_HIGH, "Writing %s.\n", name); gi.cprintf(NULL, PRINT_HIGH, "Writing %s.\n", name);

View file

@ -1637,7 +1637,7 @@ Sys_Error(char *error, ...)
char text[1024]; char text[1024];
va_start(argptr, error); va_start(argptr, error);
vsnprintf(text, sizeof(text), error, argptr); vsprintf(text, error, argptr);
va_end(argptr); va_end(argptr);
ri.Sys_Error(ERR_FATAL, "%s", text); ri.Sys_Error(ERR_FATAL, "%s", text);
@ -1650,7 +1650,7 @@ Com_Printf(char *fmt, ...)
char text[1024]; char text[1024];
va_start(argptr, fmt); va_start(argptr, fmt);
vsnprintf(text, sizeof(text), fmt, argptr); vsprintf(text, fmt, argptr);
va_end(argptr); va_end(argptr);
ri.Con_Printf(PRINT_ALL, "%s", text); ri.Con_Printf(PRINT_ALL, "%s", text);

View file

@ -408,7 +408,7 @@ SV_ConSay_f(void)
p[strlen(p) - 1] = 0; p[strlen(p) - 1] = 0;
} }
Q_strlcat(text, p, sizeof(text)); strcat(text, p);
for (j = 0, client = svs.clients; j < maxclients->value; j++, client++) for (j = 0, client = svs.clients; j < maxclients->value; j++, client++)
{ {

View file

@ -368,8 +368,8 @@ SVC_RemoteCommand(void)
for (i = 2; i < Cmd_Argc(); i++) for (i = 2; i < Cmd_Argc(); i++)
{ {
Q_strlcat(remaining, Cmd_Argv(i), sizeof(remaining)); strcat(remaining, Cmd_Argv(i));
Q_strlcat(remaining, " ", sizeof(remaining)); strcat(remaining, " ");
} }
Cmd_ExecuteString(remaining); Cmd_ExecuteString(remaining);

View file

@ -78,7 +78,7 @@ PF_dprintf(char *fmt, ...)
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
vsnprintf(msg, sizeof(msg), fmt, argptr); vsprintf(msg, fmt, argptr);
va_end(argptr); va_end(argptr);
Com_Printf("%s", msg); Com_Printf("%s", msg);
@ -107,7 +107,7 @@ PF_cprintf(edict_t *ent, int level, char *fmt, ...)
} }
va_start(argptr, fmt); va_start(argptr, fmt);
vsnprintf(msg, sizeof(msg), fmt, argptr); vsprintf(msg, fmt, argptr);
va_end(argptr); va_end(argptr);
if (ent) if (ent)
@ -138,7 +138,7 @@ PF_centerprintf(edict_t *ent, char *fmt, ...)
} }
va_start(argptr, fmt); va_start(argptr, fmt);
vsnprintf(msg, sizeof(msg), fmt, argptr); vsprintf(msg, fmt, argptr);
va_end(argptr); va_end(argptr);
MSG_WriteByte(&sv.multicast, svc_centerprint); MSG_WriteByte(&sv.multicast, svc_centerprint);
@ -156,7 +156,7 @@ PF_error(char *fmt, ...)
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
vsnprintf(msg, sizeof(msg), fmt, argptr); vsprintf(msg, fmt, argptr);
va_end(argptr); va_end(argptr);
Com_Error(ERR_DROP, "Game Error: %s", msg); Com_Error(ERR_DROP, "Game Error: %s", msg);

View file

@ -212,8 +212,7 @@ SV_SpawnServer(char *server, char *spawnpoint, server_state_t serverstate,
if (Cvar_VariableValue("deathmatch")) if (Cvar_VariableValue("deathmatch"))
{ {
snprintf(sv.configstrings[CS_AIRACCEL], sizeof(sv.configstrings[CS_AIRACCEL]), sprintf(sv.configstrings[CS_AIRACCEL], "%g", sv_airaccelerate->value);
"%g", sv_airaccelerate->value);
pm_airaccelerate = sv_airaccelerate->value; pm_airaccelerate = sv_airaccelerate->value;
} }
else else

View file

@ -95,7 +95,7 @@ SV_StatusString(void)
int playerLength; int playerLength;
strcpy(status, Cvar_Serverinfo()); strcpy(status, Cvar_Serverinfo());
Q_strlcat(status, "\n", sizeof(status)); strcat(status, "\n");
statusLength = (int)strlen(status); statusLength = (int)strlen(status);
for (i = 0; i < maxclients->value; i++) for (i = 0; i < maxclients->value; i++)

View file

@ -58,7 +58,7 @@ SV_ClientPrintf(client_t *cl, int level, char *fmt, ...)
} }
va_start(argptr, fmt); va_start(argptr, fmt);
vsnprintf(string, sizeof(string), fmt, argptr); vsprintf(string, fmt, argptr);
va_end(argptr); va_end(argptr);
MSG_WriteByte(&cl->netchan.message, svc_print); MSG_WriteByte(&cl->netchan.message, svc_print);
@ -78,7 +78,7 @@ SV_BroadcastPrintf(int level, char *fmt, ...)
int i; int i;
va_start(argptr, fmt); va_start(argptr, fmt);
vsnprintf(string, sizeof(string), fmt, argptr); vsprintf(string, fmt, argptr);
va_end(argptr); va_end(argptr);
/* echo to console */ /* echo to console */
@ -130,7 +130,7 @@ SV_BroadcastCommand(char *fmt, ...)
} }
va_start(argptr, fmt); va_start(argptr, fmt);
vsnprintf(string, sizeof(string), fmt, argptr); vsprintf(string, fmt, argptr);
va_end(argptr); va_end(argptr);
MSG_WriteByte(&sv.multicast, svc_stufftext); MSG_WriteByte(&sv.multicast, svc_stufftext);