From dbbfda0e96037da4f208ff8f00d181a5294484ae Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 22 Jun 2013 22:30:13 -0700 Subject: add new stuff stuff (with tests!), poison memcmp and strncpy --- src/map/npc.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/map/npc.cpp') diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 91331cb..ab6892a 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -205,8 +205,7 @@ int npc_event_doall_l(const char *name, int rid, int argc, argrec_t *args) int c = 0; char buf[64] = "::"; - strncpy(buf + 2, name, sizeof(buf)-3); - buf[sizeof(buf)-1] = '\0'; + strzcpy(buf + 2, name, 62); for (auto& pair : ev_db) npc_event_doall_sub(pair.first, &pair.second, &c, buf, rid, argc, args); return c; @@ -1624,10 +1623,8 @@ dumb_ptr npc_spawn_text(map_local *m, int x, int y, retval->bl_type = BL::NPC; retval->npc_subtype = NpcSubtype::MESSAGE; - strncpy(retval->name, name, 23); - strncpy(retval->exname, name, 23); - retval->name[15] = 0; - retval->exname[15] = 0; + strzcpy(retval->name, name, 24); + strzcpy(retval->exname, name, 24); if (message) retval->message = message; -- cgit v1.2.3-70-g09d2