From 8a6f7e1f79146f6989bc921152f2fc539d44aa0f Mon Sep 17 00:00:00 2001 From: Florian Wilkemeyer Date: Tue, 15 Dec 2015 16:41:34 +0100 Subject: Fixed some too long char buffer initializers. - While they don't really cause an overflow (in C), there's no point in initializing strings to "\0". - Original commit message was: Found some static-assignment overflows -> fixed. Signed-off-by: Haru --- src/map/map.c | 20 ++++++++++++-------- src/map/script.c | 6 +++--- 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/map/map.c b/src/map/map.c index e1bf5232a..149a50a7f 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -3911,8 +3911,9 @@ struct map_zone_data *map_merge_zone(struct map_zone_data *main, struct map_zone return zone; } -void map_zone_change2(int m, struct map_zone_data *zone) { - char empty[1] = "\0"; +void map_zone_change2(int m, struct map_zone_data *zone) +{ + const char *empty = ""; if( map->list[m].zone == zone ) return; @@ -3938,10 +3939,11 @@ void map_zone_change(int m, struct map_zone_data *zone, const char* start, const map->zone_apply(m,zone,start,buffer,filepath); } /* removes previous mapflags from this map */ -void map_zone_remove(int m) { +void map_zone_remove(int m) +{ char flag[MAP_ZONE_MAPFLAG_LENGTH], params[MAP_ZONE_MAPFLAG_LENGTH]; unsigned short k; - char empty[1] = "\0"; + const char *empty = ""; for(k = 0; k < map->list[m].zone_mf_count; k++) { size_t len = strlen(map->list[m].zone_mf[k]),j; params[0] = '\0'; @@ -4665,9 +4667,10 @@ bool map_zone_mf_cache(int m, char *flag, char *params) { return false; } -void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath) { +void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath) +{ int i; - char empty[1] = "\0"; + const char *empty = ""; char flag[MAP_ZONE_MAPFLAG_LENGTH], params[MAP_ZONE_MAPFLAG_LENGTH]; map->list[m].zone = zone; for(i = 0; i < zone->mapflags_count; i++) { @@ -4690,10 +4693,11 @@ void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const } } /* used on npc load and reload to apply all "Normal" and "PK Mode" zones */ -void map_zone_init(void) { +void map_zone_init(void) +{ char flag[MAP_ZONE_MAPFLAG_LENGTH], params[MAP_ZONE_MAPFLAG_LENGTH]; struct map_zone_data *zone; - char empty[1] = "\0"; + const char *empty = ""; int i,k,j; zone = &map->zone_all; diff --git a/src/map/script.c b/src/map/script.c index b73918c64..27313c401 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11747,9 +11747,9 @@ BUILDIN(setmapflag) { case MF_NOWARPTO: map->list[m].flag.nowarpto = 1; break; case MF_NIGHTMAREDROP: map->list[m].flag.pvp_nightmaredrop = 1; break; case MF_ZONE: - if( val2 ) { - char zone[6] = "zone\0"; - char empty[1] = "\0"; + if (val2 != NULL) { + const char *zone = "zone"; + const char *empty = ""; char params[MAP_ZONE_MAPFLAG_LENGTH]; memcpy(params, val2, MAP_ZONE_MAPFLAG_LENGTH); npc->parse_mapflag(map->list[m].name, empty, zone, params, empty, empty, empty, NULL); -- cgit v1.2.3-60-g2f50