diff options
author | Simon Howard | 2014-03-30 18:50:35 -0400 |
---|---|---|
committer | Simon Howard | 2014-03-30 18:50:35 -0400 |
commit | 6bb5f78bd2bdf10ddbb087171c6f640d425c9d40 (patch) | |
tree | 7e1139bcc7928983b8dd2556991be6076b95ed35 /src/heretic | |
parent | 4465be140a27e47aa8bed15be4e58064297c7d94 (diff) | |
download | chocolate-doom-6bb5f78bd2bdf10ddbb087171c6f640d425c9d40.tar.gz chocolate-doom-6bb5f78bd2bdf10ddbb087171c6f640d425c9d40.tar.bz2 chocolate-doom-6bb5f78bd2bdf10ddbb087171c6f640d425c9d40.zip |
heretic: Eliminate use of sprintf().
Use snprintf() in place of sprintf(). This is part of fixing #371.
Diffstat (limited to 'src/heretic')
-rw-r--r-- | src/heretic/am_map.c | 5 | ||||
-rw-r--r-- | src/heretic/d_main.c | 4 | ||||
-rw-r--r-- | src/heretic/f_finale.c | 2 | ||||
-rw-r--r-- | src/heretic/i_sound.c | 32 | ||||
-rw-r--r-- | src/heretic/p_saveg.c | 7 | ||||
-rw-r--r-- | src/heretic/sb_bar.c | 14 |
6 files changed, 35 insertions, 29 deletions
diff --git a/src/heretic/am_map.c b/src/heretic/am_map.c index 5454ba54..fb2d0f72 100644 --- a/src/heretic/am_map.c +++ b/src/heretic/am_map.c @@ -411,7 +411,7 @@ void AM_loadPics(void) //char namebuf[9]; /* for (i=0;i<10;i++) { - sprintf(namebuf, "AMMNUM%d", i); + snprintf(namebuf, sizeof(namebuf), "AMMNUM%d", i); marknums[i] = W_CacheLumpName(namebuf, PU_STATIC); }*/ maplump = W_CacheLumpName(DEH_String("AUTOPAGE"), PU_STATIC); @@ -603,7 +603,8 @@ boolean AM_Responder(event_t * ev) } else if (key == key_map_mark) { - sprintf(buffer, "%s %d", AMSTR_MARKEDSPOT, markpointnum); + snprintf(buffer, sizeof(buffer), "%s %d", + AMSTR_MARKEDSPOT, markpointnum); plr->message = buffer; AM_addMark(); } diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c index d0fdc582..81fa6c0d 100644 --- a/src/heretic/d_main.c +++ b/src/heretic/d_main.c @@ -247,7 +247,7 @@ void D_DoomLoop(void) if (M_CheckParm("-debugfile")) { char filename[20]; - sprintf(filename, "debug%i.txt", consoleplayer); + snprintf(filename, sizeof(filename), "debug%i.txt", consoleplayer); debugfile = fopen(filename, "w"); } I_GraphicsCheckCommandLine(); @@ -776,7 +776,7 @@ void D_BindVariables(void) { char buf[12]; - sprintf(buf, "chatmacro%i", i); + snprintf(buf, sizeof(buf), "chatmacro%i", i); M_BindVariable(buf, &chat_macros[i]); } } diff --git a/src/heretic/f_finale.c b/src/heretic/f_finale.c index 1592dac4..7978e45b 100644 --- a/src/heretic/f_finale.c +++ b/src/heretic/f_finale.c @@ -405,7 +405,7 @@ void F_BunnyScroll(void) laststage = stage; } - sprintf(name, "END%i", stage); + snprintf(name, sizeof(name), "END%i", stage); V_DrawPatch((SCREENWIDTH - 13 * 8) / 2, (SCREENHEIGHT - 8 * 8) / 2, W_CacheLumpName(name, PU_CACHE)); } diff --git a/src/heretic/i_sound.c b/src/heretic/i_sound.c index d3f04767..2dc66239 100644 --- a/src/heretic/i_sound.c +++ b/src/heretic/i_sound.c @@ -211,7 +211,8 @@ int I_GetSfxLumpNum(sfxinfo_t * sound) return 0; if (sound->link) sound = sound->link; -// sprintf(namebuf, "d%c%s", snd_prefixen[snd_SfxDevice], sound->name); +// snprintf(namebuf, sizeof(namebuf), "d%c%s", +// snd_prefixen[snd_SfxDevice], sound->name); return W_GetNumForName(sound->name); } @@ -319,14 +320,15 @@ void I_sndArbitrateCards(void) { if (debugmode) { - sprintf(tmp, "cfg p=0x%x, i=%d, d=%d\n", - snd_SBport, snd_SBirq, snd_SBdma); + snprintf(tmp, sizeof(tmp), "cfg p=0x%x, i=%d, d=%d\n", + snd_SBport, snd_SBirq, snd_SBdma); tprintf(tmp, 0); } if (SB_Detect(&snd_SBport, &snd_SBirq, &snd_SBdma, 0)) { - sprintf(tmp, "SB isn't responding at p=0x%x, i=%d, d=%d\n", - snd_SBport, snd_SBirq, snd_SBdma); + snprintf(tmp, sizeof(tmp), + "SB isn't responding at p=0x%x, i=%d, d=%d\n", + snd_SBport, snd_SBirq, snd_SBdma); tprintf(tmp, 0); } else @@ -334,8 +336,8 @@ void I_sndArbitrateCards(void) if (debugmode) { - sprintf(tmp, "SB_Detect returned p=0x%x,i=%d,d=%d\n", - snd_SBport, snd_SBirq, snd_SBdma); + snprintf(tmp, sizeof(tmp), "SB_Detect returned p=0x%x,i=%d,d=%d\n", + snd_SBport, snd_SBirq, snd_SBdma); tprintf(tmp, 0); } } @@ -352,14 +354,14 @@ void I_sndArbitrateCards(void) { if (debugmode) { - sprintf(tmp, "cfg p=0x%x\n", snd_Mport); + snprintf(tmp, sizeof(tmp), "cfg p=0x%x\n", snd_Mport); tprintf(tmp, 0); } if (MPU_Detect(&snd_Mport, &i)) { - sprintf(tmp, "The MPU-401 isn't reponding @ p=0x%x.\n", - snd_Mport); + snprintf(tmp, sizeof(tmp), + "The MPU-401 isn't reponding @ p=0x%x.\n", snd_Mport); tprintf(tmp, 0); } else @@ -397,11 +399,11 @@ void I_StartupSound(void) if (debugmode) { - sprintf(tmp, " Music device #%d & dmxCode=%d", snd_MusicDevice, - dmxCodes[snd_MusicDevice]); + snprintf(tmp, sizeof(tmp), " Music device #%d & dmxCode=%d", + snd_MusicDevice, dmxCodes[snd_MusicDevice]); tprintf(tmp, 0); - sprintf(tmp, " Sfx device #%d & dmxCode=%d\n", snd_SfxDevice, - dmxCodes[snd_SfxDevice]); + snprintf(tmp, sizeof(tmp), " Sfx device #%d & dmxCode=%d\n", + snd_SfxDevice, dmxCodes[snd_SfxDevice]); tprintf(tmp, 0); } @@ -412,7 +414,7 @@ void I_StartupSound(void) if (debugmode) { - sprintf(tmp, " DMX_Init() returned %d", rc); + snprintf(tmp, sizeof(tmp), " DMX_Init() returned %d", rc); tprintf(tmp, 0); } diff --git a/src/heretic/p_saveg.c b/src/heretic/p_saveg.c index a7ca3be0..27e6423c 100644 --- a/src/heretic/p_saveg.c +++ b/src/heretic/p_saveg.c @@ -51,9 +51,12 @@ static byte *savebuffer, *save_p; char *SV_Filename(int slot) { char *filename; + size_t filename_len; - filename = malloc(strlen(savegamedir) + strlen(SAVEGAMENAME) + 8); - sprintf(filename, "%s" SAVEGAMENAME "%d.hsg", savegamedir, slot); + filename_len = strlen(savegamedir) + strlen(SAVEGAMENAME) + 8; + filename = malloc(filename_len); + snprintf(filename, filename_len, + "%s" SAVEGAMENAME "%d.hsg", savegamedir, slot); return filename; } diff --git a/src/heretic/sb_bar.c b/src/heretic/sb_bar.c index 3de57cb1..0a2da956 100644 --- a/src/heretic/sb_bar.c +++ b/src/heretic/sb_bar.c @@ -484,20 +484,20 @@ static void DrawSoundInfo(void) MN_DrTextA(DEH_String("------"), xPos[0], y); continue; } - sprintf(text, "%s", c->name); + snprintf(text, sizeof(text), "%s", c->name); M_ForceUppercase(text); MN_DrTextA(text, xPos[x++], y); - sprintf(text, "%d", c->mo->type); + snprintf(text, sizeof(text), "%d", c->mo->type); MN_DrTextA(text, xPos[x++], y); - sprintf(text, "%d", c->mo->x >> FRACBITS); + snprintf(text, sizeof(text), "%d", c->mo->x >> FRACBITS); MN_DrTextA(text, xPos[x++], y); - sprintf(text, "%d", c->mo->y >> FRACBITS); + snprintf(text, sizeof(text), "%d", c->mo->y >> FRACBITS); MN_DrTextA(text, xPos[x++], y); - sprintf(text, "%d", c->id); + snprintf(text, sizeof(text), "%d", c->id); MN_DrTextA(text, xPos[x++], y); - sprintf(text, "%d", c->priority); + snprintf(text, sizeof(text), "%d", c->priority); MN_DrTextA(text, xPos[x++], y); - sprintf(text, "%d", c->distance); + snprintf(text, sizeof(text), "%d", c->distance); MN_DrTextA(text, xPos[x++], y); } UpdateState |= I_FULLSCRN; |