From ac647aba756a9ec08c9ed5ee01549db9409bf5a4 Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 14 Jul 2016 00:39:39 +0200 Subject: Fixed Coverity CID 150316: Copy into fixed size buffer Fixes a buffer overflow Signed-off-by: Haru --- src/map/guild.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/map/guild.c b/src/map/guild.c index ae3887aca..83afc9538 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -416,20 +416,18 @@ int guild_request_info(int guild_id) //Information request with event int guild_npc_request_info(int guild_id,const char *event) { - if( guild->search(guild_id) ) - { - if( event && *event ) + if (guild->search(guild_id) != NULL) { + if (event != NULL && *event != '\0') npc->event_do(event); return 0; } - if( event && *event ) - { + if (event != NULL && *event != '\0') { struct eventlist *ev; struct DBData prev; - ev=(struct eventlist *)aCalloc(sizeof(struct eventlist),1); - memcpy(ev->name,event,strlen(event)); + CREATE(ev, struct eventlist, 1); + safestrncpy(ev->name, event, sizeof(ev->name)); //The one in the db (if present) becomes the next event from this. if (guild->infoevent_db->put(guild->infoevent_db, DB->i2key(guild_id), DB->ptr2data(ev), &prev)) ev->next = DB->data2ptr(&prev); -- cgit v1.2.3-70-g09d2