From eb3a4033c7d6f1d5e042edd5f416bbc257e40975 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 29 Mar 2014 21:49:57 -0400 Subject: strife: Eliminate use of unsafe string functions. Eliminate use of strcpy, strcat, strncpy, and use the new safe alternatives. --- src/strife/p_dialog.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/strife/p_dialog.c') diff --git a/src/strife/p_dialog.c b/src/strife/p_dialog.c index 070288aa..95723a56 100644 --- a/src/strife/p_dialog.c +++ b/src/strife/p_dialog.c @@ -38,6 +38,7 @@ #include "doomstat.h" #include "m_random.h" #include "m_menu.h" +#include "m_misc.h" #include "r_main.h" #include "v_video.h" #include "p_local.h" @@ -719,7 +720,7 @@ boolean P_GiveItemToPlayer(player_t *player, int sprnum, mobjtype_t type) { if(mobjinfo[type].name) { - strncpy(pickupstring, DEH_String(mobjinfo[type].name), 39); + M_StringCopy(pickupstring, DEH_String(mobjinfo[type].name), 39); player->message = pickupstring; } player->questflags |= 1 << (type - MT_TOKEN_QUEST1); @@ -1132,10 +1133,9 @@ static void P_DialogDrawer(void) if(currentdialog->choices[i].needamounts[0] > 0) { // haleyjd 20120401: necessary to avoid undefined behavior: - strcpy(choicetext2, choicetext); + M_StringCopy(choicetext2, choicetext, sizeof(choicetext2)); DEH_snprintf(choicetext, sizeof(choicetext), - "%s for %d", - choicetext2, + "%s for %d", choicetext2, currentdialog->choices[i].needamounts[0]); } @@ -1228,7 +1228,7 @@ void P_DialogDoChoice(int choice) { DEH_snprintf(mission_objective, OBJECTIVE_LEN, "log%i", objective); objlump = W_CacheLumpName(mission_objective, PU_CACHE); - strncpy(mission_objective, objlump, OBJECTIVE_LEN); + M_StringCopy(mission_objective, objlump, OBJECTIVE_LEN); } // haleyjd 20130301: v1.31 hack: if first char of message is a period, // clear the player's message. Is this actually used anywhere? -- cgit v1.2.3