diff options
author | Haru <haru@dotalux.com> | 2016-07-14 00:39:39 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-07-14 00:39:39 +0200 |
commit | ac647aba756a9ec08c9ed5ee01549db9409bf5a4 (patch) | |
tree | 75258e64fb17452064b284d5ee4c4ece839b39eb /src | |
parent | dc32fdce0284cc3ad9a6eb17fb98c58334453678 (diff) | |
download | hercules-ac647aba756a9ec08c9ed5ee01549db9409bf5a4.tar.gz hercules-ac647aba756a9ec08c9ed5ee01549db9409bf5a4.tar.bz2 hercules-ac647aba756a9ec08c9ed5ee01549db9409bf5a4.tar.xz hercules-ac647aba756a9ec08c9ed5ee01549db9409bf5a4.zip |
Fixed Coverity CID 150316: Copy into fixed size buffer
Fixes a buffer overflow
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/map/guild.c | 12 |
1 files changed, 5 insertions, 7 deletions
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); |