mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-25 05:41:42 +00:00
Clean up stringop-truncation warnings
This commit is contained in:
parent
53d74e7f89
commit
703ee972e6
16 changed files with 91 additions and 86 deletions
|
@ -310,9 +310,7 @@ target_compile_options(SRB2SDL2 PRIVATE
|
|||
|
||||
$<$<VERSION_GREATER_EQUAL:$<C_COMPILER_VERSION>,8.1.0>:
|
||||
-Wno-error=format-overflow
|
||||
-Wno-error=stringop-truncation
|
||||
-Wno-format-overflow
|
||||
-Wno-stringop-truncation
|
||||
-Wno-error=multistatement-macros
|
||||
>
|
||||
|
||||
|
|
|
@ -135,9 +135,7 @@ ifdef GCC71
|
|||
endif
|
||||
ifdef GCC81
|
||||
WFLAGS+=-Wno-error=format-overflow
|
||||
WFLAGS+=-Wno-error=stringop-truncation
|
||||
WFLAGS+=-Wno-format-overflow
|
||||
WFLAGS+=-Wno-stringop-truncation
|
||||
WFLAGS+=-Wno-error=multistatement-macros
|
||||
endif
|
||||
|
||||
|
|
|
@ -2060,16 +2060,16 @@ void CV_StealthSet(consvar_t *var, const char *value)
|
|||
*/
|
||||
static void CV_SetValueMaybeStealth(consvar_t *var, INT32 value, boolean stealth)
|
||||
{
|
||||
char val[SKINNAMESIZE+1];
|
||||
char val[SKINNAMESIZE+1] = "None";
|
||||
|
||||
if (var == &cv_forceskin) // Special handling.
|
||||
{
|
||||
const char *tmpskin = NULL;
|
||||
if ((value < 0) || (value >= numskins))
|
||||
tmpskin = "None";
|
||||
;
|
||||
else
|
||||
tmpskin = skins[value]->name;
|
||||
strncpy(val, tmpskin, SKINNAMESIZE);
|
||||
memcpy(val, tmpskin, SKINNAMESIZE);
|
||||
}
|
||||
else
|
||||
sprintf(val, "%d", value);
|
||||
|
|
|
@ -324,7 +324,7 @@ void readPlayer(MYFILE *f, INT32 num)
|
|||
if (fastcmp(word, "PICNAME"))
|
||||
{
|
||||
SLOTFOUND
|
||||
strncpy(description[num].picname, word2, 8);
|
||||
strncpy(description[num].picname, word2, sizeof(description[num].picname)-1);
|
||||
}
|
||||
else if (fastcmp(word, "DISPLAYNAME"))
|
||||
{
|
||||
|
@ -355,7 +355,7 @@ void readPlayer(MYFILE *f, INT32 num)
|
|||
else if (fastcmp(word, "NAMETAG") || fastcmp(word, "TAGNAME"))
|
||||
{
|
||||
SLOTFOUND
|
||||
strncpy(description[num].nametag, word2, 8);
|
||||
strncpy(description[num].nametag, word2, sizeof(description[num].nametag)-1);
|
||||
}
|
||||
else if (fastcmp(word, "TAGTEXTCOLOR") || fastcmp(word, "TAGTEXTCOLOUR"))
|
||||
{
|
||||
|
@ -1163,7 +1163,7 @@ void readgametype(MYFILE *f, char *gtname)
|
|||
INT16 newgtrankingstype = -1;
|
||||
int newgtinttype = 0;
|
||||
char gtdescription[441];
|
||||
char gtconst[MAXLINELEN];
|
||||
char gtconst[MAXLINELEN+1];
|
||||
|
||||
// Empty strings.
|
||||
gtdescription[0] = '\0';
|
||||
|
@ -1677,7 +1677,7 @@ void readlevelheader(MYFILE *f, INT32 num)
|
|||
else if (fastcmp(word, "SKYNUM"))
|
||||
mapheaderinfo[num-1]->skynum = (INT16)i;
|
||||
else if (fastcmp(word, "INTERSCREEN"))
|
||||
strncpy(mapheaderinfo[num-1]->interscreen, word2, 8);
|
||||
strncpy(mapheaderinfo[num-1]->interscreen, word2, sizeof(mapheaderinfo[num-1]->interscreen)-1);
|
||||
else if (fastcmp(word, "PRECUTSCENENUM"))
|
||||
mapheaderinfo[num-1]->precutscenenum = (UINT8)i;
|
||||
else if (fastcmp(word, "CUTSCENENUM"))
|
||||
|
@ -2294,7 +2294,7 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum)
|
|||
char name[34];
|
||||
name[0] = '\x82'; // color yellow
|
||||
name[1] = 0;
|
||||
strncat(name, word2, 33);
|
||||
strncat(name, word2, 32);
|
||||
name[33] = 0;
|
||||
|
||||
// Replace _ with ' '
|
||||
|
@ -2304,7 +2304,7 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum)
|
|||
name[j] = ' ';
|
||||
}
|
||||
|
||||
strncpy(textprompts[num]->page[pagenum].name, name, 32);
|
||||
strncpy(textprompts[num]->page[pagenum].name, name, sizeof(textprompts[num]->page[pagenum].name));
|
||||
}
|
||||
else
|
||||
*textprompts[num]->page[pagenum].name = '\0';
|
||||
|
@ -3794,7 +3794,7 @@ void readmaincfg(MYFILE *f)
|
|||
}
|
||||
else if (fastcmp(word, "TITLEPICSNAME"))
|
||||
{
|
||||
strncpy(ttname, word2, 9);
|
||||
strncpy(ttname, word2, sizeof(ttname)-1);
|
||||
titlechanged = true;
|
||||
}
|
||||
else if (fastcmp(word, "TITLEPICSX"))
|
||||
|
@ -3878,8 +3878,12 @@ void readmaincfg(MYFILE *f)
|
|||
savemoddata = true;
|
||||
|
||||
// Also save a time attack folder
|
||||
filenamelen = strlen(gamedatafilename)-4; // Strip off the extension
|
||||
strncpy(timeattackfolder, gamedatafilename, min(filenamelen, sizeof (timeattackfolder)));
|
||||
filenamelen = strlen(gamedatafilename); // Strip off the extension
|
||||
if (filenamelen >= 4)
|
||||
filenamelen -= 4;
|
||||
if (filenamelen >= sizeof(timeattackfolder))
|
||||
filenamelen = sizeof(timeattackfolder)-1;
|
||||
strncpy(timeattackfolder, gamedatafilename, filenamelen);
|
||||
timeattackfolder[min(filenamelen, sizeof (timeattackfolder) - 1)] = '\0';
|
||||
|
||||
strcpy(savegamename, timeattackfolder);
|
||||
|
|
|
@ -165,7 +165,7 @@ extern boolean exitfadestarted;
|
|||
typedef struct
|
||||
{
|
||||
UINT8 numpics;
|
||||
char picname[8][8];
|
||||
char picname[8][8+1];
|
||||
UINT8 pichires[8];
|
||||
char *text;
|
||||
UINT16 xcoord[8];
|
||||
|
@ -296,69 +296,69 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
// The original eight, plus one.
|
||||
char lvlttl[22]; ///< Level name without "Zone". (21 character limit instead of 32, 21 characters can display on screen max anyway)
|
||||
char subttl[33]; ///< Subtitle for level
|
||||
UINT8 actnum; ///< Act number or 0 for none.
|
||||
UINT32 typeoflevel; ///< Combination of typeoflevel flags.
|
||||
INT16 nextlevel; ///< Map number of next level, or 1100-1102 to end.
|
||||
INT16 marathonnext; ///< See nextlevel, but for Marathon mode. Necessary to support hub worlds ala SUGOI.
|
||||
char keywords[33]; ///< Keywords separated by space to search for. 32 characters.
|
||||
char musname[7]; ///< Music track to play. "" for no music.
|
||||
UINT16 mustrack; ///< Subsong to play. Only really relevant for music modules and specific formats supported by GME. 0 to ignore.
|
||||
UINT32 muspos; ///< Music position to jump to.
|
||||
char forcecharacter[17]; ///< (SKINNAMESIZE+1) Skin to switch to or "" to disable.
|
||||
UINT8 weather; ///< 0 = sunny day, 1 = storm, 2 = snow, 3 = rain, 4 = blank, 5 = thunder w/o rain, 6 = rain w/o lightning, 7 = heat wave.
|
||||
INT16 skynum; ///< Sky number to use.
|
||||
INT16 skybox_scalex; ///< Skybox X axis scale. (0 = no movement, 1 = 1:1 movement, 16 = 16:1 slow movement, -4 = 1:4 fast movement, etc.)
|
||||
INT16 skybox_scaley; ///< Skybox Y axis scale.
|
||||
INT16 skybox_scalez; ///< Skybox Z axis scale.
|
||||
char lvlttl[21+1]; ///< Level name without "Zone". (21 character limit instead of 32, 21 characters can display on screen max anyway)
|
||||
char subttl[32+1]; ///< Subtitle for level
|
||||
UINT8 actnum; ///< Act number or 0 for none.
|
||||
UINT32 typeoflevel; ///< Combination of typeoflevel flags.
|
||||
INT16 nextlevel; ///< Map number of next level, or 1100-1102 to end.
|
||||
INT16 marathonnext; ///< See nextlevel, but for Marathon mode. Necessary to support hub worlds ala SUGOI.
|
||||
char keywords[32+1]; ///< Keywords separated by space to search for. 32 characters.
|
||||
char musname[7]; ///< Music track to play. "" for no music.
|
||||
UINT16 mustrack; ///< Subsong to play. Only really relevant for music modules and specific formats supported by GME. 0 to ignore.
|
||||
UINT32 muspos; ///< Music position to jump to.
|
||||
char forcecharacter[16+1]; ///< (SKINNAMESIZE+1) Skin to switch to or "" to disable.
|
||||
UINT8 weather; ///< 0 = sunny day, 1 = storm, 2 = snow, 3 = rain, 4 = blank, 5 = thunder w/o rain, 6 = rain w/o lightning, 7 = heat wave.
|
||||
INT16 skynum; ///< Sky number to use.
|
||||
INT16 skybox_scalex; ///< Skybox X axis scale. (0 = no movement, 1 = 1:1 movement, 16 = 16:1 slow movement, -4 = 1:4 fast movement, etc.)
|
||||
INT16 skybox_scaley; ///< Skybox Y axis scale.
|
||||
INT16 skybox_scalez; ///< Skybox Z axis scale.
|
||||
|
||||
// Extra information.
|
||||
char interscreen[8]; ///< 320x200 patch to display at intermission.
|
||||
char runsoc[33]; ///< SOC to execute at start of level (32 character limit instead of 63)
|
||||
char scriptname[33]; ///< Script to use when the map is switched to. (32 character limit instead of 191)
|
||||
UINT8 precutscenenum; ///< Cutscene number to play BEFORE a level starts.
|
||||
UINT8 cutscenenum; ///< Cutscene number to use, 0 for none.
|
||||
INT16 countdown; ///< Countdown until level end?
|
||||
UINT16 palette; ///< PAL lump to use on this map
|
||||
UINT8 numlaps; ///< Number of laps in circuit mode, unless overridden.
|
||||
SINT8 unlockrequired; ///< Is an unlockable required to play this level? -1 if no.
|
||||
UINT8 levelselect; ///< Is this map available in the level select? If so, which map list is it available in?
|
||||
SINT8 bonustype; ///< What type of bonus does this level have? (-1 for null.)
|
||||
SINT8 maxbonuslives; ///< How many bonus lives to award at Intermission? (-1 for unlimited.)
|
||||
char interscreen[8+1]; ///< 320x200 patch to display at intermission.
|
||||
char runsoc[32+1]; ///< SOC to execute at start of level (32 character limit instead of 63)
|
||||
char scriptname[32+1]; ///< Script to use when the map is switched to. (32 character limit instead of 191)
|
||||
UINT8 precutscenenum; ///< Cutscene number to play BEFORE a level starts.
|
||||
UINT8 cutscenenum; ///< Cutscene number to use, 0 for none.
|
||||
INT16 countdown; ///< Countdown until level end?
|
||||
UINT16 palette; ///< PAL lump to use on this map
|
||||
UINT8 numlaps; ///< Number of laps in circuit mode, unless overridden.
|
||||
SINT8 unlockrequired; ///< Is an unlockable required to play this level? -1 if no.
|
||||
UINT8 levelselect; ///< Is this map available in the level select? If so, which map list is it available in?
|
||||
SINT8 bonustype; ///< What type of bonus does this level have? (-1 for null.)
|
||||
SINT8 maxbonuslives; ///< How many bonus lives to award at Intermission? (-1 for unlimited.)
|
||||
|
||||
UINT16 levelflags; ///< LF_flags: merged booleans into one UINT16 for space, see below
|
||||
UINT8 menuflags; ///< LF2_flags: options that affect record attack / nights mode menus
|
||||
UINT16 levelflags; ///< LF_flags: merged booleans into one UINT16 for space, see below
|
||||
UINT8 menuflags; ///< LF2_flags: options that affect record attack / nights mode menus
|
||||
|
||||
char selectheading[22]; ///< Level select heading. Allows for controllable grouping.
|
||||
UINT16 startrings; ///< Number of rings players start with.
|
||||
INT32 sstimer; ///< Timer for special stages.
|
||||
UINT32 ssspheres; ///< Sphere requirement in special stages.
|
||||
fixed_t gravity; ///< Map-wide gravity.
|
||||
char selectheading[22]; ///< Level select heading. Allows for controllable grouping.
|
||||
UINT16 startrings; ///< Number of rings players start with.
|
||||
INT32 sstimer; ///< Timer for special stages.
|
||||
UINT32 ssspheres; ///< Sphere requirement in special stages.
|
||||
fixed_t gravity; ///< Map-wide gravity.
|
||||
|
||||
// Title card.
|
||||
char ltzzpatch[9]; ///< Zig zag patch.
|
||||
char ltzztext[9]; ///< Zig zag text.
|
||||
char ltactdiamond[9]; ///< Act diamond.
|
||||
char ltzzpatch[8+1]; ///< Zig zag patch.
|
||||
char ltzztext[8+1]; ///< Zig zag text.
|
||||
char ltactdiamond[8+1]; ///< Act diamond.
|
||||
|
||||
// Freed animals stuff.
|
||||
UINT8 numFlickies; ///< Internal. For freed flicky support.
|
||||
mobjtype_t *flickies; ///< List of freeable flickies in this level. Allocated dynamically for space reasons. Be careful.
|
||||
UINT8 numFlickies; ///< Internal. For freed flicky support.
|
||||
mobjtype_t *flickies; ///< List of freeable flickies in this level. Allocated dynamically for space reasons. Be careful.
|
||||
|
||||
// NiGHTS stuff.
|
||||
UINT8 numGradedMares; ///< Internal. For grade support.
|
||||
nightsgrades_t *grades; ///< NiGHTS grades. Allocated dynamically for space reasons. Be careful.
|
||||
UINT8 numGradedMares; ///< Internal. For grade support.
|
||||
nightsgrades_t *grades; ///< NiGHTS grades. Allocated dynamically for space reasons. Be careful.
|
||||
|
||||
// Music stuff.
|
||||
UINT32 musinterfadeout; ///< Fade out level music on intermission screen in milliseconds
|
||||
char musintername[7]; ///< Intermission screen music.
|
||||
UINT32 musinterfadeout; ///< Fade out level music on intermission screen in milliseconds
|
||||
char musintername[7]; ///< Intermission screen music.
|
||||
|
||||
char muspostbossname[7]; ///< Post-bossdeath music.
|
||||
UINT16 muspostbosstrack; ///< Post-bossdeath track.
|
||||
UINT32 muspostbosspos; ///< Post-bossdeath position
|
||||
UINT32 muspostbossfadein; ///< Post-bossdeath fade-in milliseconds.
|
||||
|
||||
SINT8 musforcereset; ///< Force resetmusic (-1 for default; 0 for force off; 1 for force on)
|
||||
SINT8 musforcereset; ///< Force resetmusic (-1 for default; 0 for force off; 1 for force on)
|
||||
|
||||
// Lua stuff.
|
||||
// (This is not ifdeffed so the map header structure can stay identical, just in case.)
|
||||
|
|
|
@ -96,7 +96,7 @@ typedef enum
|
|||
extern ttmode_enum ttmode;
|
||||
extern UINT8 ttscale;
|
||||
// ttmode user vars
|
||||
extern char ttname[9];
|
||||
extern char ttname[8+1];
|
||||
extern INT16 ttx;
|
||||
extern INT16 tty;
|
||||
extern INT16 ttloop;
|
||||
|
|
|
@ -496,10 +496,10 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags)
|
|||
// what we're gonna do now is check if the player exists
|
||||
// with that logic, characters 4 and 5 are our numbers:
|
||||
const char *newmsg;
|
||||
char playernum[3];
|
||||
char playernum[3+1];
|
||||
INT32 spc = 1; // used if playernum[1] is a space.
|
||||
|
||||
strncpy(playernum, msg+3, 3);
|
||||
strncpy(playernum, msg+3, sizeof(playernum)-1);
|
||||
// check for undesirable characters in our "number"
|
||||
if (((playernum[0] < '0') || (playernum[0] > '9')) || ((playernum[1] < '0') || (playernum[1] > '9')))
|
||||
{
|
||||
|
@ -969,7 +969,7 @@ static void HU_sendChatMessage(void)
|
|||
if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
|
||||
{
|
||||
INT32 spc = 1; // used if playernum[1] is a space.
|
||||
char playernum[3];
|
||||
char playernum[3+1];
|
||||
const char *newmsg;
|
||||
|
||||
// what we're gonna do now is check if the player exists
|
||||
|
@ -982,7 +982,7 @@ static void HU_sendChatMessage(void)
|
|||
return;
|
||||
}
|
||||
|
||||
strncpy(playernum, msg+3, 3);
|
||||
strncpy(playernum, msg+3, sizeof(playernum)-1);
|
||||
// check for undesirable characters in our "number"
|
||||
if (!(isdigit(playernum[0]) && isdigit(playernum[1])))
|
||||
{
|
||||
|
@ -1679,13 +1679,14 @@ static void HU_DrawChat(void)
|
|||
// filter: (code needs optimization pls help I'm bad with C)
|
||||
if (w_chat[3])
|
||||
{
|
||||
char playernum[3];
|
||||
char playernum[3+1];
|
||||
UINT32 n;
|
||||
// right, that's half important: (w_chat[4] may be a space since /pm0 msg is perfectly acceptable!)
|
||||
if ( ( ((w_chat[3] != 0) && ((w_chat[3] < '0') || (w_chat[3] > '9'))) || ((w_chat[4] != 0) && (((w_chat[4] < '0') || (w_chat[4] > '9'))))) && (w_chat[4] != ' '))
|
||||
break;
|
||||
|
||||
strncpy(playernum, w_chat+3, 3);
|
||||
strncpy(playernum, w_chat+3, sizeof(playernum)-1);
|
||||
playernum[3] = 0;
|
||||
n = atoi(playernum); // turn that into a number
|
||||
// special cases:
|
||||
|
||||
|
@ -3052,7 +3053,7 @@ void HU_DoCEcho(const char *msg)
|
|||
{
|
||||
I_OutputMsg("%s\n", msg); // print to log
|
||||
|
||||
strncpy(cechotext, msg, sizeof(cechotext));
|
||||
strncpy(cechotext, msg, sizeof(cechotext)-1);
|
||||
strncat(cechotext, "\\", sizeof(cechotext) - strlen(cechotext) - 1);
|
||||
cechotext[sizeof(cechotext) - 1] = '\0';
|
||||
cechotimer = cechoduration;
|
||||
|
|
|
@ -2692,7 +2692,7 @@ static boolean MIT_SetCurTitlePics(UINT32 menutype, INT32 level, INT32 *retval,
|
|||
curhidepics = menupres[menutype].hidetitlepics;
|
||||
curttmode = menupres[menutype].ttmode;
|
||||
curttscale = (menupres[menutype].ttscale != UINT8_MAX ? menupres[menutype].ttscale : ttscale);
|
||||
strncpy(curttname, menupres[menutype].ttname, 9);
|
||||
strncpy(curttname, menupres[menutype].ttname, sizeof(curttname)-1);
|
||||
curttx = (menupres[menutype].ttx != INT16_MAX ? menupres[menutype].ttx : ttx);
|
||||
curtty = (menupres[menutype].tty != INT16_MAX ? menupres[menutype].tty : tty);
|
||||
curttloop = (menupres[menutype].ttloop != INT16_MAX ? menupres[menutype].ttloop : ttloop);
|
||||
|
@ -11282,7 +11282,8 @@ static void M_DrawRoomMenu(void)
|
|||
if (dot_frame < 0)
|
||||
dot_frame = 0;
|
||||
|
||||
strncpy(&text[dot_frame], "...", min(dots, 3 - dot_frame));
|
||||
if (dot_frame != 3)
|
||||
strncpy(&text[dot_frame], "...", min(dots, 3 - dot_frame));
|
||||
}
|
||||
|
||||
frame += renderdeltatics;
|
||||
|
|
|
@ -378,7 +378,7 @@ typedef struct
|
|||
char displayname[SKINNAMESIZE+1];
|
||||
INT16 skinnum[2];
|
||||
UINT16 oppositecolor;
|
||||
char nametag[8];
|
||||
char nametag[8+1];
|
||||
patch_t *namepic;
|
||||
UINT16 tagtextcolor;
|
||||
UINT16 tagoutlinecolor;
|
||||
|
|
|
@ -307,7 +307,7 @@ boolean CL_SendJoin(void)
|
|||
else
|
||||
player2name = cv_playername2.zstring;
|
||||
|
||||
strncpy(netbuffer->u.clientcfg.names[0], cv_playername.zstring, MAXPLAYERNAME);
|
||||
strncpy(netbuffer->u.clientcfg.names[0], cv_playername.zstring, sizeof(netbuffer->u.clientcfg.names[0])-1);
|
||||
strncpy(netbuffer->u.clientcfg.names[1], player2name, MAXPLAYERNAME);
|
||||
|
||||
return HSendPacket(servernode, true, 0, sizeof (clientconfig_pak));
|
||||
|
|
|
@ -115,12 +115,12 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
|
|||
netbuffer->u.serverinfo.refusereason = GetRefuseReason(node);
|
||||
|
||||
strncpy(netbuffer->u.serverinfo.gametypename, Gametype_Names[gametype],
|
||||
sizeof netbuffer->u.serverinfo.gametypename);
|
||||
sizeof(netbuffer->u.serverinfo.gametypename)-1);
|
||||
netbuffer->u.serverinfo.modifiedgame = (UINT8)modifiedgame;
|
||||
netbuffer->u.serverinfo.cheatsenabled = CV_CheatsEnabled();
|
||||
netbuffer->u.serverinfo.flags = (dedicated ? SV_DEDICATED : 0);
|
||||
strncpy(netbuffer->u.serverinfo.servername, cv_servername.string,
|
||||
MAXSERVERNAME);
|
||||
sizeof(netbuffer->u.serverinfo.servername)-1);
|
||||
strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), 7);
|
||||
|
||||
M_Memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, 16);
|
||||
|
@ -184,7 +184,9 @@ static void SV_SendPlayerInfo(INT32 node)
|
|||
}
|
||||
|
||||
netbuffer->u.playerinfo[i].num = i;
|
||||
strncpy(netbuffer->u.playerinfo[i].name, (const char *)&player_names[i], MAXPLAYERNAME+1);
|
||||
memset(netbuffer->u.playerinfo[i].name, 0x00, sizeof(netbuffer->u.playerinfo[i].name));
|
||||
memcpy(netbuffer->u.playerinfo[i].name, player_names[i], sizeof(player_names[i]));
|
||||
|
||||
netbuffer->u.playerinfo[i].name[MAXPLAYERNAME] = '\0';
|
||||
|
||||
//fetch IP address
|
||||
|
|
|
@ -363,7 +363,7 @@ void P_ParseAnimationDefintion(SINT8 istexture)
|
|||
// Increase the size to make room for the new animation definition
|
||||
maxanims++;
|
||||
animdefs = (animdef_t *)Z_Realloc(animdefs, sizeof(animdef_t)*(maxanims + 1), PU_STATIC, NULL);
|
||||
strncpy(animdefs[i].startname, animdefsToken, 9);
|
||||
strncpy(animdefs[i].startname, animdefsToken, sizeof(animdefs[i].startname)-1);
|
||||
}
|
||||
|
||||
// animdefs[i].startname is now set to animdefsToken either way.
|
||||
|
|
|
@ -1910,7 +1910,7 @@ static void S_AddMusicStackEntry(const char *mname, UINT16 mflags, boolean loopi
|
|||
if (!music_stacks)
|
||||
{
|
||||
music_stacks = Z_Calloc(sizeof (*mst), PU_MUSIC, NULL);
|
||||
strncpy(music_stacks->musname, (status == JT_MASTER ? mname : (S_CheckQueue() ? queue_name : mapmusname)), 7);
|
||||
strncpy(music_stacks->musname, (status == JT_MASTER ? mname : (S_CheckQueue() ? queue_name : mapmusname)), sizeof(music_stacks->musname)-1);
|
||||
music_stacks->musflags = (status == JT_MASTER ? mflags : (S_CheckQueue() ? queue_flags : mapmusflags));
|
||||
music_stacks->looping = (status == JT_MASTER ? looping : (S_CheckQueue() ? queue_looping : true));
|
||||
music_stacks->position = (status == JT_MASTER ? position : (S_CheckQueue() ? queue_position : S_GetMusicPosition()));
|
||||
|
@ -2033,7 +2033,7 @@ boolean S_RecallMusic(UINT16 status, boolean fromfirst)
|
|||
if (result)
|
||||
{
|
||||
*entry = *result;
|
||||
strncpy(entry->musname, result->musname, 7);
|
||||
memcpy(entry->musname, result->musname, sizeof(entry->musname));
|
||||
}
|
||||
|
||||
// no result, just grab mapmusname
|
||||
|
@ -2255,7 +2255,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
|
|||
if (S_MusicDisabled())
|
||||
return;
|
||||
|
||||
strncpy(newmusic, mmusic, 7);
|
||||
strncpy(newmusic, mmusic, sizeof(newmusic)-1);
|
||||
if (LUA_HookMusicChange(music_name, &hook_param))
|
||||
return;
|
||||
newmusic[6] = 0;
|
||||
|
|
|
@ -238,7 +238,7 @@ UINT32 S_GetMusicPosition(void);
|
|||
|
||||
typedef struct musicstack_s
|
||||
{
|
||||
char musname[7];
|
||||
char musname[7+1];
|
||||
UINT16 musflags;
|
||||
boolean looping;
|
||||
UINT32 position;
|
||||
|
|
|
@ -1700,7 +1700,7 @@ const char *I_GetJoyName(INT32 joyindex)
|
|||
{
|
||||
tempname = SDL_JoystickNameForIndex(joyindex);
|
||||
if (tempname)
|
||||
strncpy(joyname, tempname, 255);
|
||||
strncpy(joyname, tempname, sizeof(joyname)-1);
|
||||
}
|
||||
return joyname;
|
||||
}
|
||||
|
|
|
@ -384,13 +384,14 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue)
|
|||
|
||||
const char *R_GetPalname(UINT16 num)
|
||||
{
|
||||
static char palname[9];
|
||||
char newpal[9] = "PLAYPAL";
|
||||
static char palname[8+1];
|
||||
char newpal[9] = "PLAYPAL\0";
|
||||
|
||||
if (num > 0 && num <= 10000)
|
||||
snprintf(newpal, 8, "PAL%04u", num-1);
|
||||
|
||||
strncpy(palname, newpal, 8);
|
||||
strncpy(palname, newpal, sizeof(palname)-1);
|
||||
palname[8] = 0;
|
||||
return palname;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue