diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-07-27 01:08:15 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-07-27 01:40:12 +0300 |
commit | 415860ebaeb990c0c8da27cc7aa565a137b97fe9 (patch) | |
tree | 379bc512894f445da63207d58c0956ea503a5f01 /src/map/mob.c | |
parent | 30ba171e28b10c5f9355cab5902fa311a234d833 (diff) | |
download | hercules-415860ebaeb990c0c8da27cc7aa565a137b97fe9.tar.gz hercules-415860ebaeb990c0c8da27cc7aa565a137b97fe9.tar.bz2 hercules-415860ebaeb990c0c8da27cc7aa565a137b97fe9.tar.xz hercules-415860ebaeb990c0c8da27cc7aa565a137b97fe9.zip |
Fix possible buffer overflows with snprintf.
Diffstat (limited to 'src/map/mob.c')
-rw-r--r-- | src/map/mob.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/map/mob.c b/src/map/mob.c index 52705cf4d..98f8865a9 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -3350,7 +3350,7 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) { char name[NAME_LENGTH]; snprintf(name, sizeof name,"%s", md->name); strtok(name, "#"); // discard extra name identifier if present [Daegaladh] - snprintf(temp, sizeof temp,"%s : %s", name, mc->msg); + safesnprintf(temp, sizeof temp,"%s : %s", name, mc->msg); clif->messagecolor(&md->bl, mc->color, temp); } if(!(battle_config.mob_ai&0x200)) { //pass on delay to same skill. @@ -4494,7 +4494,7 @@ int mob_read_libconfig(const char *filename, bool ignore_missing) int i = 0, count = 0; nullpo_ret(filename); - sprintf(filepath, "%s/%s", map->db_path, filename); + safesnprintf(filepath, sizeof(filepath), "%s/%s", map->db_path, filename); if (ignore_missing && !exists(filepath)) return 0; @@ -4720,7 +4720,7 @@ void mob_readchatdb(void) { char line[1024], filepath[256]; int i, tmp=0; FILE *fp; - sprintf(filepath, "%s/%s", map->db_path, arc); + safesnprintf(filepath, sizeof(filepath), "%s/%s", map->db_path, arc); fp=fopen(filepath, "r"); if(fp == NULL) { ShowWarning("mob_readchatdb: File not found \"%s\", skipping.\n", filepath); @@ -5046,7 +5046,7 @@ void mob_readskilldb(void) { for( fi = 0; fi < ARRAYLENGTH(filename); ++fi ) { if(fi > 0) { char filepath[256]; - snprintf(filepath, 256, "%s/%s", map->db_path, filename[fi]); + safesnprintf(filepath, 256, "%s/%s", map->db_path, filename[fi]); if(!exists(filepath)) { continue; } |