From 737925f2950ef82406a088b4e35dedd0966364c3 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 27 Aug 2000 10:30:17 +0000 Subject: [PATCH] sprintf -> snprintf bash and sed rule! :) --- source/cl_demo.c | 2 +- source/cl_main.c | 4 ++-- source/console.c | 10 +++++----- source/cvar.c | 2 +- source/draw.c | 2 +- source/gl_model.c | 2 +- source/gl_rmain.c | 2 +- source/gl_screen.c | 2 +- source/host.c | 10 +++++----- source/host_cmd.c | 14 +++++++------- source/keys.c | 6 +++--- source/menu.c | 12 ++++++------ source/model.c | 2 +- source/mplpc.c | 2 +- source/net_bw.c | 2 +- source/net_comx.c | 4 ++-- source/net_dgrm.c | 2 +- source/net_ipx.c | 6 +++--- source/net_mp.c | 2 +- source/net_ser.c | 4 ++-- source/net_udp.c | 2 +- source/net_wins.c | 4 ++-- source/net_wipx.c | 6 +++--- source/pr_cmds.c | 8 ++++---- source/pr_edict.c | 44 ++++++++++++++++++++++---------------------- source/pr_exec.c | 2 +- source/r_part.c | 2 +- source/sbar.c | 22 +++++++++++----------- source/screen.c | 2 +- source/sv_main.c | 8 ++++---- source/sys_dos.c | 6 +++--- source/sys_unix.c | 8 ++++---- source/sys_unixd.c | 8 ++++---- source/sys_win.c | 8 ++++---- source/sys_wind.c | 2 +- source/vid_dos.c | 6 +++--- source/vid_ext.c | 8 ++++---- source/vid_svgalib.c | 2 +- source/vid_win.c | 36 ++++++++++++++++++------------------ 39 files changed, 138 insertions(+), 138 deletions(-) diff --git a/source/cl_demo.c b/source/cl_demo.c index 588e6eb..e8613dd 100644 --- a/source/cl_demo.c +++ b/source/cl_demo.c @@ -250,7 +250,7 @@ void CL_Record_f (void) else track = -1; - sprintf (name, "%s/%s", com_gamedir, Cmd_Argv(1)); + snprintf (name, sizeof(name), "%s/%s", com_gamedir, Cmd_Argv(1)); // // start the map up diff --git a/source/cl_main.c b/source/cl_main.c index a02c61f..86d1640 100644 --- a/source/cl_main.c +++ b/source/cl_main.c @@ -219,7 +219,7 @@ Con_DPrintf ("CL_SignonReply: %i\n", cls.signon); MSG_WriteString (&cls.message, va("color %i %i\n", ((int)cl_color->value)>>4, ((int)cl_color->value)&15)); MSG_WriteByte (&cls.message, clc_stringcmd); - sprintf (str, "spawn %s", cls.spawnparms); + snprintf (str, sizeof(str), "spawn %s", cls.spawnparms); MSG_WriteString (&cls.message, str); break; @@ -262,7 +262,7 @@ void CL_NextDemo (void) } } - sprintf (str,"playdemo %s\n", cls.demos[cls.demonum]); + snprintf (str, sizeof(str), "playdemo %s\n", cls.demos[cls.demonum]); Cbuf_InsertText (str); cls.demonum++; } diff --git a/source/console.c b/source/console.c index a0a79f0..04a9bed 100644 --- a/source/console.c +++ b/source/console.c @@ -242,7 +242,7 @@ void Con_Init (void) { if (strlen (com_gamedir) < (MAXGAMEDIRLEN - strlen (t2))) { - sprintf (temp, "%s%s", com_gamedir, t2); + snprintf (temp, sizeof(temp), "%s%s", com_gamedir, t2); unlink (temp); } } @@ -378,7 +378,7 @@ void Con_DebugLog(char *file, char *fmt, ...) int fd; va_start(argptr, fmt); - vsprintf(data, fmt, argptr); + vsnprintf (data, sizeof(data), fmt, argptr); va_end(argptr); fd = open(file, O_WRONLY | O_CREAT | O_APPEND, 0666); write(fd, data, strlen(data)); @@ -402,7 +402,7 @@ void Con_Printf (char *fmt, ...) static qboolean inupdate; va_start (argptr,fmt); - vsprintf (msg,fmt,argptr); + vsnprintf (msg, sizeof(msg), fmt,argptr); va_end (argptr); // also echo to debugging console @@ -451,7 +451,7 @@ void Con_DPrintf (char *fmt, ...) return; // don't confuse non-developers with techie stuff... va_start (argptr,fmt); - vsprintf (msg,fmt,argptr); + vsnprintf (msg, sizeof(msg), fmt,argptr); va_end (argptr); Con_Printf ("%s", msg); @@ -472,7 +472,7 @@ void Con_SafePrintf (char *fmt, ...) int temp; va_start (argptr,fmt); - vsprintf (msg,fmt,argptr); + vsnprintf (msg, sizeof(msg), fmt,argptr); va_end (argptr); temp = scr_disabled_for_loading; diff --git a/source/cvar.c b/source/cvar.c index 43ee288..8fa3506 100644 --- a/source/cvar.c +++ b/source/cvar.c @@ -242,7 +242,7 @@ void Cvar_SetValue (cvar_t *var_name, float value) char val[32]; int i; - sprintf (val, "%f", value); + snprintf (val, sizeof(val), "%f", value); for (i=strlen(val)-1 ; i>0 && val[i]=='0' && val[i-1]!='.' ; i--) { val[i] = 0; diff --git a/source/draw.c b/source/draw.c index 18f5a69..85026f5 100644 --- a/source/draw.c +++ b/source/draw.c @@ -561,7 +561,7 @@ void Draw_ConsoleBackground (int lines) conback = Draw_CachePic ("gfx/conback.lmp"); // hack the version number directly into the pic - sprintf (ver, "%s, version %s", PROGRAM, VERSION); + snprintf (ver, sizeof(ver), "%s, version %s", PROGRAM, VERSION); dest = conback->data + 320*186 + 320 - 11 - 8*strlen(ver); for (x=0 ; xleafs = out; loadmodel->numleafs = count; - //sprintf(s, "maps/%s.bsp", Info_ValueForKey(cl.serverinfo,"map")); + //snprintf (s, sizeof(s), "maps/%s.bsp", Info_ValueForKey(cl.serverinfo,"map")); if (!strncmp("maps/", loadmodel->name,5)) isnotmap = false; for ( i=0 ; igl_texturenum[currententity->skinnum][anim]); + glBindTexture (GL_TEXTURE_2D, paliashdr->gl_texturenum[currententity->skinnum][anim]); // we can't dynamically colormap textures, so they are cached // seperately for the players. Heads are just uncolored. diff --git a/source/gl_screen.c b/source/gl_screen.c index 2ff8c90..edfa924 100644 --- a/source/gl_screen.c +++ b/source/gl_screen.c @@ -630,7 +630,7 @@ void SCR_ScreenShot_f (void) { pcxname[5] = i/10 + '0'; pcxname[6] = i%10 + '0'; - sprintf (checkname, "%s/%s", com_gamedir, pcxname); + snprintf (checkname, sizeof(checkname), "%s/%s", com_gamedir, pcxname); if (Sys_FileTime(checkname) == -1) break; // file doesn't exist } diff --git a/source/host.c b/source/host.c index 89f13bc..c10c22f 100644 --- a/source/host.c +++ b/source/host.c @@ -121,7 +121,7 @@ void Host_EndGame (char *message, ...) char string[1024]; va_start (argptr,message); - vsprintf (string,message,argptr); + vsnprintf (string, sizeof(string), message,argptr); va_end (argptr); Con_DPrintf ("Host_EndGame: %s\n",string); @@ -159,7 +159,7 @@ void Host_Error (char *error, ...) SCR_EndLoadingPlaque (); // reenable screen updates va_start (argptr,error); - vsprintf (string,error,argptr); + vsnprintf (string, sizeof(string), error,argptr); va_end (argptr); Con_Printf ("Host_Error: %s\n",string); @@ -308,7 +308,7 @@ void SV_ClientPrintf (char *fmt, ...) char string[1024]; va_start (argptr,fmt); - vsprintf (string, fmt,argptr); + vsnprintf (string, sizeof(string), fmt,argptr); va_end (argptr); MSG_WriteByte (&host_client->message, svc_print); @@ -329,7 +329,7 @@ void SV_BroadcastPrintf (char *fmt, ...) int i; va_start (argptr,fmt); - vsprintf (string, fmt,argptr); + vsnprintf (string, sizeof(string), fmt,argptr); va_end (argptr); for (i=0 ; imessage, svc_stufftext); diff --git a/source/host_cmd.c b/source/host_cmd.c index 725140c..713cc21 100644 --- a/source/host_cmd.c +++ b/source/host_cmd.c @@ -468,7 +468,7 @@ void Host_SavegameComment (char *text) for (i=0 ; iname); + snprintf (text, sizeof(text), "%c%s: ", 1, save->name); else - sprintf (text, "%c<%s> ", 1, hostname->string); + snprintf (text, sizeof(text), "%c<%s> ", 1, hostname->string); j = sizeof(text) - 2 - strlen(text); // -2 for /n and null terminator if (strlen(p) > j) diff --git a/source/keys.c b/source/keys.c index fdefa7a..0346c2d 100644 --- a/source/keys.c +++ b/source/keys.c @@ -690,7 +690,7 @@ void Key_Event (int key, qboolean down) kb = keybindings[key]; if (kb && kb[0] == '+') { - sprintf (cmd, "-%s %i\n", kb+1, key); + snprintf (cmd, sizeof(cmd), "-%s %i\n", kb+1, key); Cbuf_AddText (cmd); } if (keyshift[key] != key) @@ -698,7 +698,7 @@ void Key_Event (int key, qboolean down) kb = keybindings[keyshift[key]]; if (kb && kb[0] == '+') { - sprintf (cmd, "-%s %i\n", kb+1, key); + snprintf (cmd, sizeof(cmd), "-%s %i\n", kb+1, key); Cbuf_AddText (cmd); } } @@ -726,7 +726,7 @@ void Key_Event (int key, qboolean down) { if (kb[0] == '+') { // button commands add keynum as a parm - sprintf (cmd, "%s %i\n", kb, key); + snprintf (cmd, sizeof(cmd), "%s %i\n", kb, key); Cbuf_AddText (cmd); } else diff --git a/source/menu.c b/source/menu.c index e8ebbc5..f1a2eeb 100644 --- a/source/menu.c +++ b/source/menu.c @@ -480,7 +480,7 @@ void M_ScanSaves (void) { strcpy (m_filenames[i], "--- UNUSED SLOT ---"); loadable[i] = false; - sprintf (name, "%s/s%i.sav", com_gamedir, i); + snprintf (name, sizeof(name), "%s/s%i.sav", com_gamedir, i); f = fopen (name, "r"); if (!f) continue; @@ -1483,7 +1483,7 @@ void M_Keys_Key (int k) } else if (k != '`') { - sprintf (cmd, "bind \"%s\" \"%s\"\n", Key_KeynumToString (k), bindnames[keys_cursor][0]); + snprintf (cmd, sizeof(cmd), "bind \"%s\" \"%s\"\n", Key_KeynumToString (k), bindnames[keys_cursor][0]); Cbuf_InsertText (cmd); } @@ -2228,7 +2228,7 @@ void M_Menu_LanConfig_f (void) if (StartingGame && lanConfig_cursor == 2) lanConfig_cursor = 1; lanConfig_port = DEFAULTnet_hostport; - sprintf(lanConfig_portname, "%u", lanConfig_port); + snprintf (lanConfig_portname, sizeof(lanConfig_portname), "%u", lanConfig_port); m_return_onerror = false; m_return_reason[0] = 0; @@ -2402,7 +2402,7 @@ void M_LanConfig_Key (int key) l = lanConfig_port; else lanConfig_port = l; - sprintf(lanConfig_portname, "%u", lanConfig_port); + snprintf (lanConfig_portname, sizeof(lanConfig_portname), "%u", lanConfig_port); } //============================================================================= @@ -2969,9 +2969,9 @@ void M_ServerList_Draw (void) for (n = 0; n < hostCacheCount; n++) { if (hostcache[n].maxusers) - sprintf(string, "%-15.15s %-15.15s %2u/%2u\n", hostcache[n].name, hostcache[n].map, hostcache[n].users, hostcache[n].maxusers); + snprintf (string, sizeof(string), "%-15.15s %-15.15s %2u/%2u\n", hostcache[n].name, hostcache[n].map, hostcache[n].users, hostcache[n].maxusers); else - sprintf(string, "%-15.15s %-15.15s\n", hostcache[n].name, hostcache[n].map); + snprintf (string, sizeof(string), "%-15.15s %-15.15s\n", hostcache[n].name, hostcache[n].map); M_Print (16, 32 + 8*n, string); } M_DrawCharacter (0, 32 + slist_cursor*8, 12+((int)(realtime*4)&1)); diff --git a/source/model.c b/source/model.c index ee68abc..3c6b027 100644 --- a/source/model.c +++ b/source/model.c @@ -1220,7 +1220,7 @@ void Mod_LoadBrushModel (model_t *mod, void *buffer) { // duplicate the basic information char name[10]; - sprintf (name, "*%i", i+1); + snprintf (name, sizeof(name), "*%i", i+1); loadmodel = Mod_FindName (name); *loadmodel = *mod; strcpy (loadmodel->name, name); diff --git a/source/mplpc.c b/source/mplpc.c index f995d56..532a77c 100644 --- a/source/mplpc.c +++ b/source/mplpc.c @@ -1009,6 +1009,6 @@ char *inet_ntoa (struct in_addr in) { static char buf [32]; - sprintf(buf, "%u.%u.%u.%u", in.S_un.S_un_b.s_b1, in.S_un.S_un_b.s_b2, in.S_un.S_un_b.s_b3, in.S_un.S_un_b.s_b4); + snprintf (buf, sizeof(buf), "%u.%u.%u.%u", in.S_un.S_un_b.s_b1, in.S_un.S_un_b.s_b2, in.S_un.S_un_b.s_b3, in.S_un.S_un_b.s_b4); return buf; } diff --git a/source/net_bw.c b/source/net_bw.c index 6eee3bb..4daaa5f 100644 --- a/source/net_bw.c +++ b/source/net_bw.c @@ -631,7 +631,7 @@ char *BW_AddrToString (struct qsockaddr *addr) { static char buffer[22]; - sprintf(buffer, "%d.%d.%d.%d:%d", + snprintf (buffer, sizeof(buffer), "%d.%d.%d.%d:%d", ((struct sockaddr_in *)addr)->sin_addr.s_net, ((struct sockaddr_in *)addr)->sin_addr.s_host, ((struct sockaddr_in *)addr)->sin_addr.s_lh, diff --git a/source/net_comx.c b/source/net_comx.c index 63261d0..684b71f 100644 --- a/source/net_comx.c +++ b/source/net_comx.c @@ -783,7 +783,7 @@ int TTY_Connect(int handle, char *host) key_count = -2; Con_Printf ("Dialing...\n"); - sprintf(dialstring, "AT D%c %s\r", p->dialType, host); + snprintf (dialstring, sizeof(dialstring), "AT D%c %s\r", p->dialType, host); Modem_Command (p, dialstring); start = Sys_DoubleTime(); while(1) @@ -1156,7 +1156,7 @@ int TTY_Init(void) handleToPort[n] = p; p->portNumber = n; p->dialType = 'T'; - sprintf(p->name, "com%u", n+1); + snprintf (p->name, sizeof(p->name), "com%u", n+1); Cmd_AddCommand (p->name, Com_f); ResetComPortConfig (p); } diff --git a/source/net_dgrm.c b/source/net_dgrm.c index 4c9408a..5753a4d 100644 --- a/source/net_dgrm.c +++ b/source/net_dgrm.c @@ -116,7 +116,7 @@ char *StrAddr (struct qsockaddr *addr) int n; for (n = 0; n < 16; n++) - sprintf (buf + n * 2, "%02x", *p++); + snprintf (buf + n * 2, sizeof(buf + n * 2), "%02x", *p++); return buf; } #endif diff --git a/source/net_ipx.c b/source/net_ipx.c index c157346..a3a26a0 100644 --- a/source/net_ipx.c +++ b/source/net_ipx.c @@ -587,7 +587,7 @@ char *IPX_AddrToString (struct qsockaddr *addr) { static char buf[28]; - sprintf(buf, "%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%u", + snprintf (buf, sizeof(buf), "%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%u", ((struct sockaddr_ipx *)addr)->sipx_addr.network[0], ((struct sockaddr_ipx *)addr)->sipx_addr.network[1], ((struct sockaddr_ipx *)addr)->sipx_addr.network[2], @@ -669,12 +669,12 @@ int IPX_GetAddrFromName (char *name, struct qsockaddr *addr) if (n == 12) { - sprintf(buf, "00000000:%s:%u", name, net_hostport); + snprintf (buf, sizeof(buf), "00000000:%s:%u", name, net_hostport); return IPX_StringToAddr (buf, addr); } if (n == 21) { - sprintf(buf, "%s:%u", name, net_hostport); + snprintf (buf, sizeof(buf), "%s:%u", name, net_hostport); return IPX_StringToAddr (buf, addr); } if (n > 21 && n <= 27) diff --git a/source/net_mp.c b/source/net_mp.c index 421b019..85273f4 100644 --- a/source/net_mp.c +++ b/source/net_mp.c @@ -345,7 +345,7 @@ char *MPATH_AddrToString (struct qsockaddr *addr) int haddr; haddr = ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr); - sprintf(buffer, "%d.%d.%d.%d:%d", (haddr >> 24) & 0xff, (haddr >> 16) & 0xff, (haddr >> 8) & 0xff, haddr & 0xff, ntohs(((struct sockaddr_in *)addr)->sin_port)); + snprintf (buffer, sizeof(buffer), "%d.%d.%d.%d:%d", (haddr >> 24) & 0xff, (haddr >> 16) & 0xff, (haddr >> 8) & 0xff, haddr & 0xff, ntohs(((struct sockaddr_in *)addr)->sin_port)); return buffer; } diff --git a/source/net_ser.c b/source/net_ser.c index 8d1bc59..2fef6e0 100644 --- a/source/net_ser.c +++ b/source/net_ser.c @@ -759,7 +759,7 @@ void Serial_SearchForHosts (qboolean xmit) if (TTY_IsModem(p->tty)) return; - sprintf(hostcache[hostCacheCount].name, "COM%u", n+1); + snprintf (hostcache[hostCacheCount].name, sizeof(hostcache[hostCacheCount].name), "COM%u", n+1); Q_strcpy(hostcache[hostCacheCount].map, ""); hostcache[hostCacheCount].users = 0; hostcache[hostCacheCount].maxusers = 0; @@ -943,7 +943,7 @@ static qsocket_t *_Serial_CheckNewConnections (SerialLine *p) p->connected = true; p->connecting = false; p->sock->lastMessageTime = net_time; - sprintf(p->sock->address, "COM%u", (int)((p - serialLine) + 1)); + snprintf (p->sock->address, sizeof(p->sock->address), "COM%u", (int)((p - serialLine) + 1)); return p->sock; } diff --git a/source/net_udp.c b/source/net_udp.c index 610f4f6..0e53016 100644 --- a/source/net_udp.c +++ b/source/net_udp.c @@ -323,7 +323,7 @@ char *UDP_AddrToString (struct qsockaddr *addr) int haddr; haddr = ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr); - sprintf(buffer, "%d.%d.%d.%d:%d", (haddr >> 24) & 0xff, (haddr >> 16) & 0xff, (haddr >> 8) & 0xff, haddr & 0xff, ntohs(((struct sockaddr_in *)addr)->sin_port)); + snprintf (buffer, sizeof(buffer), "%d.%d.%d.%d:%d", (haddr >> 24) & 0xff, (haddr >> 16) & 0xff, (haddr >> 8) & 0xff, haddr & 0xff, ntohs(((struct sockaddr_in *)addr)->sin_port)); return buffer; } diff --git a/source/net_wins.c b/source/net_wins.c index d430afb..ecd249d 100644 --- a/source/net_wins.c +++ b/source/net_wins.c @@ -118,7 +118,7 @@ void WINS_GetLocalAddress() myAddr = *(int *)local->h_addr_list[0]; addr = ntohl(myAddr); - sprintf(my_tcpip_address, "%d.%d.%d.%d", (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff); + snprintf (my_tcpip_address, sizeof(my_tcpip_address), "%d.%d.%d.%d", (addr >> 24) & 0xff, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff); } @@ -477,7 +477,7 @@ char *WINS_AddrToString (struct qsockaddr *addr) int haddr; haddr = ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr); - sprintf(buffer, "%d.%d.%d.%d:%d", (haddr >> 24) & 0xff, (haddr >> 16) & 0xff, (haddr >> 8) & 0xff, haddr & 0xff, ntohs(((struct sockaddr_in *)addr)->sin_port)); + snprintf (buffer, sizeof(buffer), "%d.%d.%d.%d:%d", (haddr >> 24) & 0xff, (haddr >> 16) & 0xff, (haddr >> 8) & 0xff, haddr & 0xff, ntohs(((struct sockaddr_in *)addr)->sin_port)); return buffer; } diff --git a/source/net_wipx.c b/source/net_wipx.c index 54c2753..d0b5a78 100644 --- a/source/net_wipx.c +++ b/source/net_wipx.c @@ -302,7 +302,7 @@ char *WIPX_AddrToString (struct qsockaddr *addr) { static char buf[28]; - sprintf(buf, "%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%u", + snprintf (buf, sizeof(buf), "%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%u", ((struct sockaddr_ipx *)addr)->sa_netnum[0] & 0xff, ((struct sockaddr_ipx *)addr)->sa_netnum[1] & 0xff, ((struct sockaddr_ipx *)addr)->sa_netnum[2] & 0xff, @@ -390,12 +390,12 @@ int WIPX_GetAddrFromName(char *name, struct qsockaddr *addr) if (n == 12) { - sprintf(buf, "00000000:%s:%u", name, net_hostport); + snprintf (buf, sizeof(buf), "00000000:%s:%u", name, net_hostport); return WIPX_StringToAddr (buf, addr); } if (n == 21) { - sprintf(buf, "%s:%u", name, net_hostport); + snprintf (buf, sizeof(buf), "%s:%u", name, net_hostport); return WIPX_StringToAddr (buf, addr); } if (n > 21 && n <= 27) diff --git a/source/pr_cmds.c b/source/pr_cmds.c index 22695ad..5be5bb3 100644 --- a/source/pr_cmds.c +++ b/source/pr_cmds.c @@ -958,9 +958,9 @@ void PF_ftos (void) v = G_FLOAT(OFS_PARM0); if (v == (int)v) - sprintf (pr_string_temp, "%d",(int)v); + snprintf (pr_string_temp, sizeof(pr_string_temp), "%d",(int)v); else - sprintf (pr_string_temp, "%5.1f",v); + snprintf (pr_string_temp, sizeof(pr_string_temp), "%5.1f",v); G_INT(OFS_RETURN) = pr_string_temp - pr_strings; } @@ -973,14 +973,14 @@ void PF_fabs (void) void PF_vtos (void) { - sprintf (pr_string_temp, "'%5.1f %5.1f %5.1f'", G_VECTOR(OFS_PARM0)[0], G_VECTOR(OFS_PARM0)[1], G_VECTOR(OFS_PARM0)[2]); + snprintf (pr_string_temp, sizeof(pr_string_temp), "'%5.1f %5.1f %5.1f'", G_VECTOR(OFS_PARM0)[0], G_VECTOR(OFS_PARM0)[1], G_VECTOR(OFS_PARM0)[2]); G_INT(OFS_RETURN) = pr_string_temp - pr_strings; } #ifdef QUAKE2 void PF_etos (void) { - sprintf (pr_string_temp, "entity %i", G_EDICTNUM(OFS_PARM0)); + snprintf (pr_string_temp, sizeof(pr_string_temp), "entity %i", G_EDICTNUM(OFS_PARM0)); G_INT(OFS_RETURN) = pr_string_temp - pr_strings; } #endif diff --git a/source/pr_edict.c b/source/pr_edict.c index 446933a..8f68c68 100644 --- a/source/pr_edict.c +++ b/source/pr_edict.c @@ -307,33 +307,33 @@ char *PR_ValueString (etype_t type, eval_t *val) switch (type) { case ev_string: - sprintf (line, "%s", pr_strings + val->string); + snprintf (line, sizeof(line), "%s", pr_strings + val->string); break; case ev_entity: - sprintf (line, "entity %i", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict)) ); + snprintf (line, sizeof(line), "entity %i", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict)) ); break; case ev_function: f = pr_functions + val->function; - sprintf (line, "%s()", pr_strings + f->s_name); + snprintf (line, sizeof(line), "%s()", pr_strings + f->s_name); break; case ev_field: def = ED_FieldAtOfs ( val->_int ); - sprintf (line, ".%s", pr_strings + def->s_name); + snprintf (line, sizeof(line), ".%s", pr_strings + def->s_name); break; case ev_void: - sprintf (line, "void"); + snprintf (line, sizeof(line), "void"); break; case ev_float: - sprintf (line, "%5.1f", val->_float); + snprintf (line, sizeof(line), "%5.1f", val->_float); break; case ev_vector: - sprintf (line, "'%5.1f %5.1f %5.1f'", val->vector[0], val->vector[1], val->vector[2]); + snprintf (line, sizeof(line), "'%5.1f %5.1f %5.1f'", val->vector[0], val->vector[1], val->vector[2]); break; case ev_pointer: - sprintf (line, "pointer"); + snprintf (line, sizeof(line), "pointer"); break; default: - sprintf (line, "bad type %i", type); + snprintf (line, sizeof(line), "bad type %i", type); break; } @@ -359,30 +359,30 @@ char *PR_UglyValueString (etype_t type, eval_t *val) switch (type) { case ev_string: - sprintf (line, "%s", pr_strings + val->string); + snprintf (line, sizeof(line), "%s", pr_strings + val->string); break; case ev_entity: - sprintf (line, "%i", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict))); + snprintf (line, sizeof(line), "%i", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict))); break; case ev_function: f = pr_functions + val->function; - sprintf (line, "%s", pr_strings + f->s_name); + snprintf (line, sizeof(line), "%s", pr_strings + f->s_name); break; case ev_field: def = ED_FieldAtOfs ( val->_int ); - sprintf (line, "%s", pr_strings + def->s_name); + snprintf (line, sizeof(line), "%s", pr_strings + def->s_name); break; case ev_void: - sprintf (line, "void"); + snprintf (line, sizeof(line), "void"); break; case ev_float: - sprintf (line, "%f", val->_float); + snprintf (line, sizeof(line), "%f", val->_float); break; case ev_vector: - sprintf (line, "%f %f %f", val->vector[0], val->vector[1], val->vector[2]); + snprintf (line, sizeof(line), "%f %f %f", val->vector[0], val->vector[1], val->vector[2]); break; default: - sprintf (line, "bad type %i", type); + snprintf (line, sizeof(line), "bad type %i", type); break; } @@ -408,11 +408,11 @@ char *PR_GlobalString (int ofs) val = (void *)&pr_globals[ofs]; def = ED_GlobalAtOfs(ofs); if (!def) - sprintf (line,"%i(???)", ofs); + snprintf (line, sizeof(line), "%i(???)", ofs); else { s = PR_ValueString (def->type, val); - sprintf (line,"%i(%s)%s", ofs, pr_strings + def->s_name, s); + snprintf (line, sizeof(line), "%i(%s)%s", ofs, pr_strings + def->s_name, s); } i = strlen(line); @@ -431,9 +431,9 @@ char *PR_GlobalStringNoContents (int ofs) def = ED_GlobalAtOfs(ofs); if (!def) - sprintf (line,"%i(???)", ofs); + snprintf (line, sizeof(line), "%i(???)", ofs); else - sprintf (line,"%i(%s)", ofs, pr_strings + def->s_name); + snprintf (line, sizeof(line), "%i(%s)", ofs, pr_strings + def->s_name); i = strlen(line); for ( ; i<20 ; i++) @@ -892,7 +892,7 @@ if (anglehack) { char temp[32]; strcpy (temp, com_token); -sprintf (com_token, "0 %s 0", temp); +snprintf (com_token, sizeof(com_token), "0 %s 0", temp); } if (!ED_ParseEpair ((void *)&ent->v, key, com_token)) diff --git a/source/pr_exec.c b/source/pr_exec.c index 7b6c5a7..6218f1d 100644 --- a/source/pr_exec.c +++ b/source/pr_exec.c @@ -281,7 +281,7 @@ void PR_RunError (char *error, ...) char string[1024]; va_start (argptr,error); - vsprintf (string,error,argptr); + vsnprintf (string, sizeof(string), error,argptr); va_end (argptr); PR_PrintStatement (pr_statements + pr_xstatement); diff --git a/source/r_part.c b/source/r_part.c index 8483e73..dca0636 100644 --- a/source/r_part.c +++ b/source/r_part.c @@ -218,7 +218,7 @@ void R_ReadPointFile_f (void) particle_t *p; char name[MAX_OSPATH]; - sprintf (name,"maps/%s.pts", sv.name); + snprintf (name, sizeof(name), "maps/%s.pts", sv.name); COM_FOpenFile (name, &f); if (!f) diff --git a/source/sbar.c b/source/sbar.c index af73fd8..c42ba23 100644 --- a/source/sbar.c +++ b/source/sbar.c @@ -456,7 +456,7 @@ void Sbar_UpdateScoreboard (void) { k = fragsort[i]; s = &cl.scores[k]; - sprintf (&scoreboardtext[i][1], "%3i %s", s->frags, s->name); + snprintf (&scoreboardtext[i][1], sizeof(&scoreboardtext[i][1]), "%3i %s", s->frags, s->name); top = s->colors & 0xf0; bottom = (s->colors & 15) <<4; @@ -478,10 +478,10 @@ void Sbar_SoloScoreboard (void) int minutes, seconds, tens, units; int l; - sprintf (str,"Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]); + snprintf (str, sizeof(str), "Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]); Sbar_DrawString (8, 4, str); - sprintf (str,"Secrets :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]); + snprintf (str, sizeof(str), "Secrets :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]); Sbar_DrawString (8, 12, str); // time @@ -489,7 +489,7 @@ void Sbar_SoloScoreboard (void) seconds = cl.time - 60*minutes; tens = seconds / 10; units = seconds - 10*tens; - sprintf (str,"Time :%3i:%i%i", minutes, tens, units); + snprintf (str, sizeof(str), "Time :%3i:%i%i", minutes, tens, units); Sbar_DrawString (184, 4, str); // draw level name @@ -679,7 +679,7 @@ void Sbar_DrawInventory (void) // ammo counts for (i=0 ; i<4 ; i++) { - sprintf (num, "%3i",cl.stats[STAT_SHELLS+i] ); + snprintf (num, sizeof(num), "%3i",cl.stats[STAT_SHELLS+i] ); if (num[0] != ' ') Sbar_DrawCharacter ( (6*i+1)*8 - 2, -24, 18 + num[0] - '0'); if (num[1] != ' ') @@ -820,7 +820,7 @@ void Sbar_DrawFrags (void) // draw number f = s->frags; - sprintf (num, "%3i",f); + snprintf (num, sizeof(num), "%3i",f); Sbar_DrawCharacter ( (x+1)*8 , -24, num[0]); Sbar_DrawCharacter ( (x+2)*8 , -24, num[1]); @@ -877,7 +877,7 @@ void Sbar_DrawFace (void) // draw number f = s->frags; - sprintf (num, "%3i",f); + snprintf (num, sizeof(num), "%3i",f); if (top==8) { @@ -1142,7 +1142,7 @@ void Sbar_DeathmatchOverlay (void) // draw number f = s->frags; - sprintf (num, "%3i",f); + snprintf (num, sizeof(num), "%3i",f); Draw_Character8 ( x+8 , y, num[0]); Draw_Character8 ( x+16 , y, num[1]); @@ -1163,7 +1163,7 @@ void Sbar_DeathmatchOverlay (void) tens = n/10; units = n%10; - sprintf (num, "%3i:%i%i", minutes, tens, units); + snprintf (num, sizeof(num), "%3i:%i%i", minutes, tens, units); Draw_String8 ( x+48 , y, num); } @@ -1241,7 +1241,7 @@ void Sbar_MiniDeathmatchOverlay (void) // draw number f = s->frags; - sprintf (num, "%3i",f); + snprintf (num, sizeof(num), "%3i",f); Draw_Character8 ( x+8 , y, num[0]); Draw_Character8 ( x+16 , y, num[1]); @@ -1264,7 +1264,7 @@ void Sbar_MiniDeathmatchOverlay (void) tens = n/10; units = n%10; - sprintf (num, "%3i:%i%i", minutes, tens, units); + snprintf (num, sizeof(num), "%3i:%i%i", minutes, tens, units); Draw_String8 ( x+48 , y, num); } diff --git a/source/screen.c b/source/screen.c index e753462..57d9471 100644 --- a/source/screen.c +++ b/source/screen.c @@ -651,7 +651,7 @@ void SCR_ScreenShot_f (void) { pcxname[5] = i/10 + '0'; pcxname[6] = i%10 + '0'; - sprintf (checkname, "%s/%s", com_gamedir, pcxname); + snprintf (checkname, sizeof(checkname), "%s/%s", com_gamedir, pcxname); if (Sys_FileTime(checkname) == -1) break; // file doesn't exist } diff --git a/source/sv_main.c b/source/sv_main.c index 5399578..ae06734 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -65,7 +65,7 @@ void SV_Init (void) sv_nostep = Cvar_Get("sv_nostep", "0", CVAR_NONE, "None"); for (i=0 ; imessage, svc_print); - sprintf (message, "%c\nVersion %s server (%i CRC)", 2, QUAKE_VERSION, pr_crc); + snprintf (message, sizeof(message), "%c\nVersion %s server (%i CRC)", 2, QUAKE_VERSION, pr_crc); MSG_WriteString (&client->message,message); MSG_WriteByte (&client->message, svc_serverinfo); @@ -210,7 +210,7 @@ void SV_SendServerinfo (client_t *client) else MSG_WriteByte (&client->message, GAME_COOP); - sprintf (message, pr_strings+sv.edicts->v.message); + snprintf (message, sizeof(message), pr_strings+sv.edicts->v.message); MSG_WriteString (&client->message,message); @@ -1132,7 +1132,7 @@ void SV_SpawnServer (char *server) sv.time = 1.0; strcpy (sv.name, server); - sprintf (sv.modelname,"maps/%s.bsp", server); + snprintf (sv.modelname, sizeof(sv.modelname), "maps/%s.bsp", server); sv.worldmodel = Mod_ForName (sv.modelname, false); if (!sv.worldmodel) { diff --git a/source/sys_dos.c b/source/sys_dos.c index 8117bb8..674db4b 100644 --- a/source/sys_dos.c +++ b/source/sys_dos.c @@ -557,7 +557,7 @@ void Sys_Printf (char *fmt, ...) char text[1024]; va_start (argptr,fmt); - vsprintf (text,fmt,argptr); + vsnprintf (text, sizeof(text), fmt,argptr); va_end (argptr); if (cls.state == ca_dedicated) @@ -591,7 +591,7 @@ void Sys_Quit (void) memcpy (screen, d, sizeof(screen)); // write the version number directly to the end screen - sprintf (ver, " v%4.2f", VERSION); + snprintf (ver, sizeof(ver), " v%4.2f", VERSION); for (i=0 ; i<6 ; i++) screen[0*80*2 + 72*2 + i*2] = ver[i]; @@ -621,7 +621,7 @@ void Sys_Error (char *error, ...) char string[1024]; va_start (argptr,error); - vsprintf (string,error,argptr); + vsnprintf (string, sizeof(string), error,argptr); va_end (argptr); Host_Shutdown(); diff --git a/source/sys_unix.c b/source/sys_unix.c index 69a50a3..ccad267 100644 --- a/source/sys_unix.c +++ b/source/sys_unix.c @@ -193,7 +193,7 @@ Sys_DebugLog(char *file, char *fmt, ...) int fd; va_start (argptr, fmt); - vsprintf (data, fmt, argptr); + vsnprintf (data, sizeof(data), fmt, argptr); va_end (argptr); fd = open(file, O_WRONLY | O_CREAT | O_APPEND, 0666); @@ -217,7 +217,7 @@ Sys_EditFile (char *filename) editor = getenv ("EDIT"); if (!editor) editor = "vi"; - sprintf (cmd, "xterm -e %s %s", editor, filename); + snprintf (cmd, sizeof(cmd), "xterm -e %s %s", editor, filename); system (cmd); } } @@ -296,7 +296,7 @@ Sys_Error (char *error, ...) fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY); va_start (argptr,error); - vsprintf (string,error,argptr); + vsnprintf (string, sizeof(string), error,argptr); va_end (argptr); fprintf(stderr, "Error: %s\n", string); @@ -329,7 +329,7 @@ Sys_Warn (char *warning, ...) char string[1024]; va_start (argptr, warning); - vsprintf (string, warning, argptr); + vsnprintf (string, sizeof(string), warning, argptr); va_end (argptr); fprintf (stderr, "Warning: %s", string); } diff --git a/source/sys_unixd.c b/source/sys_unixd.c index 0b8364d..9e2bf4b 100644 --- a/source/sys_unixd.c +++ b/source/sys_unixd.c @@ -193,7 +193,7 @@ Sys_DebugLog(char *file, char *fmt, ...) int fd; va_start (argptr, fmt); - vsprintf (data, fmt, argptr); + vsnprintf (data, sizeof(data), fmt, argptr); va_end (argptr); fd = open(file, O_WRONLY | O_CREAT | O_APPEND, 0666); @@ -217,7 +217,7 @@ Sys_EditFile (char *filename) editor = getenv ("EDIT"); if (!editor) editor = "vi"; - sprintf (cmd, "xterm -e %s %s", editor, filename); + snprintf (cmd, sizeof(cmd), "xterm -e %s %s", editor, filename); system (cmd); } } @@ -282,7 +282,7 @@ Sys_Error (char *error, ...) fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY); va_start (argptr,error); - vsprintf (string,error,argptr); + vsnprintf (string, sizeof(string), error,argptr); va_end (argptr); fprintf(stderr, "Error: %s\n", string); @@ -315,7 +315,7 @@ Sys_Warn (char *warning, ...) char string[1024]; va_start (argptr, warning); - vsprintf (string, warning, argptr); + vsnprintf (string, sizeof(string), warning, argptr); va_end (argptr); fprintf (stderr, "Warning: %s", string); } diff --git a/source/sys_win.c b/source/sys_win.c index 3d31328..763b648 100644 --- a/source/sys_win.c +++ b/source/sys_win.c @@ -374,16 +374,16 @@ void Sys_Error (char *error, ...) } va_start (argptr, error); - vsprintf (text, error, argptr); + vsnprintf (text, sizeof(text), error, argptr); va_end (argptr); if (isDedicated) { va_start (argptr, error); - vsprintf (text, error, argptr); + vsnprintf (text, sizeof(text), error, argptr); va_end (argptr); - sprintf (text2, "ERROR: %s\n", text); + snprintf (text2, sizeof(text2), "ERROR: %s\n", text); WriteFile (houtput, text5, strlen (text5), &dummy, NULL); WriteFile (houtput, text4, strlen (text4), &dummy, NULL); WriteFile (houtput, text2, strlen (text2), &dummy, NULL); @@ -442,7 +442,7 @@ void Sys_Printf (char *fmt, ...) if (isDedicated) { va_start (argptr,fmt); - vsprintf (text, fmt, argptr); + vsnprintf (text, sizeof(text), fmt, argptr); va_end (argptr); WriteFile(houtput, text, strlen (text), &dummy, NULL); diff --git a/source/sys_wind.c b/source/sys_wind.c index c47fae2..dd08e64 100644 --- a/source/sys_wind.c +++ b/source/sys_wind.c @@ -173,7 +173,7 @@ void Sys_Error (char *error, ...) char text[1024]; va_start (argptr,error); - vsprintf (text, error,argptr); + vsnprintf (text, sizeof(text), error,argptr); va_end (argptr); // MessageBox(NULL, text, "Error", 0 /* MB_OK */ ); diff --git a/source/vid_dos.c b/source/vid_dos.c index 3e1172d..2bc80a9 100644 --- a/source/vid_dos.c +++ b/source/vid_dos.c @@ -667,7 +667,7 @@ void VID_MenuDraw (void) // line cursor if (vid_testingmode) { - sprintf (temp, "TESTING %s", + snprintf (temp, sizeof(temp), "TESTING %s", modedescs[vid_line].desc); M_Print (13*8, 36 + MAX_COLUMN_SIZE * 8 + 8*4, temp); M_Print (9*8, 36 + MAX_COLUMN_SIZE * 8 + 8*6, @@ -680,13 +680,13 @@ void VID_MenuDraw (void) M_Print (6*8, 36 + MAX_COLUMN_SIZE * 8 + 8*3, "T to test mode for 5 seconds"); ptr = VID_GetModeDescription (vid_modenum); - sprintf (temp, "D to make %s the default", ptr); + snprintf (temp, sizeof(temp), "D to make %s the default", ptr); M_Print (6*8, 36 + MAX_COLUMN_SIZE * 8 + 8*5, temp); ptr = VID_GetModeDescription ((int)_vid_default_mode->value); if (ptr) { - sprintf (temp, "Current default is %s", ptr); + snprintf (temp, sizeof(temp), "Current default is %s", ptr); M_Print (7*8, 36 + MAX_COLUMN_SIZE * 8 + 8*6, temp); } diff --git a/source/vid_ext.c b/source/vid_ext.c index 11cc789..409a736 100644 --- a/source/vid_ext.c +++ b/source/vid_ext.c @@ -343,13 +343,13 @@ void VID_InitExtra (void) { if (modeinfo.height > 999) { - sprintf (&names[nummodes][0], "%4dx%4d", modeinfo.width, + snprintf (&names[nummodes][0], sizeof(&names[nummodes][0]), "%4dx%4d", modeinfo.width, modeinfo.height); names[nummodes][9] = 0; } else { - sprintf (&names[nummodes][0], "%4dx%3d", modeinfo.width, + snprintf (&names[nummodes][0], sizeof(&names[nummodes][0]), "%4dx%3d", modeinfo.width, modeinfo.height); names[nummodes][8] = 0; } @@ -358,13 +358,13 @@ void VID_InitExtra (void) { if (modeinfo.height > 999) { - sprintf (&names[nummodes][0], "%3dx%4d", modeinfo.width, + snprintf (&names[nummodes][0], sizeof(&names[nummodes][0]), "%3dx%4d", modeinfo.width, modeinfo.height); names[nummodes][8] = 0; } else { - sprintf (&names[nummodes][0], "%3dx%3d", modeinfo.width, + snprintf (&names[nummodes][0], sizeof(&names[nummodes][0]), "%3dx%3d", modeinfo.width, modeinfo.height); names[nummodes][7] = 0; } diff --git a/source/vid_svgalib.c b/source/vid_svgalib.c index c0be52a..4fea969 100644 --- a/source/vid_svgalib.c +++ b/source/vid_svgalib.c @@ -1010,7 +1010,7 @@ char *VID_ModeInfo (int modenum) if (modenum == 0) { - sprintf (modestr, "%d x %d, %d bpp", + snprintf (modestr, sizeof(modestr), "%d x %d, %d bpp", vid.width, vid.height, modes[current_mode].bytesperpixel*8); return (modestr); } diff --git a/source/vid_win.c b/source/vid_win.c index bc6ce07..27d7d8e 100644 --- a/source/vid_win.c +++ b/source/vid_win.c @@ -510,7 +510,7 @@ void VID_InitMGLFull (HINSTANCE hInstance) modelist[curmode].type = MS_FULLSCREEN; modelist[curmode].width = xRes; modelist[curmode].height = yRes; - sprintf (modelist[curmode].modedesc, "%dx%d", xRes, yRes); + snprintf (modelist[curmode].modedesc, sizeof(modelist[curmode].modedesc), "%dx%d", xRes, yRes); if (m[i] == grVGA_320x200x256) modelist[curmode].mode13 = 1; @@ -532,7 +532,7 @@ void VID_InitMGLFull (HINSTANCE hInstance) modelist[MODE_FULLSCREEN_DEFAULT].stretched = 1; modelist[MODE_FULLSCREEN_DEFAULT].width >>= 1; modelist[MODE_FULLSCREEN_DEFAULT].height >>= 1; - sprintf (modelist[MODE_FULLSCREEN_DEFAULT].modedesc, "%dx%d", + snprintf (modelist[MODE_FULLSCREEN_DEFAULT].modedesc, sizeof(modelist[MODE_FULLSCREEN_DEFAULT].modedesc), "%dx%d", modelist[MODE_FULLSCREEN_DEFAULT].width, modelist[MODE_FULLSCREEN_DEFAULT].height); } @@ -761,7 +761,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) modelist[nummodes].dib = 1; modelist[nummodes].fullscreen = 1; modelist[nummodes].bpp = devmode.dmBitsPerPel; - sprintf (modelist[nummodes].modedesc, "%dx%d", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc), "%dx%d", devmode.dmPelsWidth, devmode.dmPelsHeight); // if the width is more than twice the height, reduce it by half because this @@ -772,7 +772,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) { modelist[nummodes].width >>= 1; modelist[nummodes].halfscreen = 1; - sprintf (modelist[nummodes].modedesc, "%dx%d", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc), "%dx%d", modelist[nummodes].width, modelist[nummodes].height); } @@ -840,7 +840,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) modelist[nummodes].dib = 1; modelist[nummodes].fullscreen = 1; modelist[nummodes].bpp = devmode.dmBitsPerPel; - sprintf (modelist[nummodes].modedesc, "%dx%d", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc), "%dx%d", devmode.dmPelsWidth, devmode.dmPelsHeight); // if the width is more than twice the height, reduce it by half because this @@ -851,7 +851,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) { modelist[nummodes].width >>= 1; modelist[nummodes].halfscreen = 1; - sprintf (modelist[nummodes].modedesc, "%dx%d", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc), "%dx%d", modelist[nummodes].width, modelist[nummodes].height); } @@ -924,7 +924,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) modelist[nummodes].dib = 1; modelist[nummodes].fullscreen = 1; modelist[nummodes].bpp = devmode.dmBitsPerPel; - sprintf (modelist[nummodes].modedesc, "%dx%d", + snprintf (modelist[nummodes].modedesc, sizeof(modelist[nummodes].modedesc), "%dx%d", devmode.dmPelsWidth, devmode.dmPelsHeight); // we only want the lowest-bpp version of each mode @@ -996,7 +996,7 @@ void VID_InitFullDIB (HINSTANCE hInstance) modelist[istretch].width >>= 1; modelist[istretch].height >>= 1; modelist[istretch].stretched = 1; - sprintf (modelist[istretch].modedesc, "%dx%d", + snprintf (modelist[istretch].modedesc, sizeof(modelist[istretch].modedesc), "%dx%d", modelist[istretch].width, modelist[istretch].height); } } @@ -1056,7 +1056,7 @@ void VID_CheckModedescFixup (int mode) x = (int)vid_config_x->value; y = (int)vid_config_y->value; - sprintf (modelist[mode].modedesc, "%dx%d", x, y); + snprintf (modelist[mode].modedesc, sizeof(modelist[mode].modedesc), "%dx%d", x, y); modelist[mode].width = x; modelist[mode].height = y; } @@ -1134,15 +1134,15 @@ char *VID_GetModeDescription2 (int mode) if (modelist[mode].type == MS_FULLSCREEN) { - sprintf(pinfo,"%s fullscreen", pv->modedesc); + snprintf (pinfo, sizeof(pinfo), "%s fullscreen", pv->modedesc); } else if (modelist[mode].type == MS_FULLDIB) { - sprintf(pinfo,"%s fullscreen", pv->modedesc); + snprintf (pinfo, sizeof(pinfo), "%s fullscreen", pv->modedesc); } else { - sprintf(pinfo, "%s windowed", pv->modedesc); + snprintf (pinfo, sizeof(pinfo), "%s windowed", pv->modedesc); } return pinfo; @@ -1164,16 +1164,16 @@ char *VID_GetExtModeDescription (int mode) pv = VID_GetModePtr (mode); if (modelist[mode].type == MS_FULLSCREEN) { - sprintf(pinfo,"%s fullscreen %s",pv->modedesc, + snprintf (pinfo, sizeof(pinfo), "%s fullscreen %s",pv->modedesc, MGL_modeDriverName(pv->modenum)); } else if (modelist[mode].type == MS_FULLDIB) { - sprintf(pinfo,"%s fullscreen DIB", pv->modedesc); + snprintf (pinfo, sizeof(pinfo), "%s fullscreen DIB", pv->modedesc); } else { - sprintf(pinfo, "%s windowed", pv->modedesc); + snprintf (pinfo, sizeof(pinfo), "%s windowed", pv->modedesc); } return pinfo; @@ -3220,7 +3220,7 @@ void VID_MenuDraw (void) // line cursor if (vid_testingmode) { - sprintf (temp, "TESTING %s", + snprintf (temp, sizeof(temp), "TESTING %s", modedescs[vid_line].desc); M_Print (13*8, 36 + MODE_AREA_HEIGHT * 8 + 8*4, temp); M_Print (9*8, 36 + MODE_AREA_HEIGHT * 8 + 8*6, @@ -3236,7 +3236,7 @@ void VID_MenuDraw (void) if (ptr) { - sprintf (temp, "D to set default: %s", ptr); + snprintf (temp, sizeof(temp), "D to set default: %s", ptr); M_Print (2*8, 36 + MODE_AREA_HEIGHT * 8 + 8*5, temp); } @@ -3244,7 +3244,7 @@ void VID_MenuDraw (void) if (ptr) { - sprintf (temp, "Current default: %s", ptr); + snprintf (temp, sizeof(temp), "Current default: %s", ptr); M_Print (3*8, 36 + MODE_AREA_HEIGHT * 8 + 8*6, temp); }