From 9a425c11b61fb6f4e299013c7d8d9841129b8f45 Mon Sep 17 00:00:00 2001 From: panikon Date: Tue, 6 May 2014 21:14:46 -0300 Subject: Bug fixes and other changes #Fixed issue where a corrupted map cache would lead to a crash *Moved Big-endian compatibility functions to common/utils.h #Fixed issue 8162 *http://hercules.ws/board/tracker/issue-8162-loadnpc-doesnt-trigger-oninit-of-duplicate-npcs/ *Added options to npc_parse_duplicate #Fixed issue 8169 *http://hercules.ws/board/tracker/issue-8169-script-command-guildskill-skill-idlevel-not-working-as-intended/ *Changed *guildskill behavior, now it behaves exactly as depicted in the documentation *Updated *guildskill documentation #Added missing GBI types to mapif_parse_GuildBasicInfoChange now it's possible to change guild exp, lv, skill point and skill information #GeoIP revamp *GeoIP module was partially rewritten *Added several data checks to prevent corruption and crashes *Updated GeoIP database *See https://github.com/maxmind/geoip-api-c/blob/master/libGeoIP/GeoIP.c for more information #Added packetver checks regarding NST_MARKET *Now *tradertype warns if user is trying to use this feature with older clients --- src/map/map.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/map/map.c') diff --git a/src/map/map.c b/src/map/map.c index 04ac8a239..11ef56cb3 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -2846,6 +2846,7 @@ int map_eraseipport(unsigned short map_index, uint32 ip, uint16 port) { * [Shinryo]: Init the mapcache *------------------------------------------*/ char *map_init_mapcache(FILE *fp) { + struct map_cache_main_header header; size_t size = 0; char *buffer; @@ -2869,6 +2870,19 @@ char *map_init_mapcache(FILE *fp) { return NULL; } + rewind(fp); + + // Get main header to verify if data is corrupted + if( fread(&header, sizeof(header), 1, fp) != 1 ) { + ShowError("map_init_mapcache: Error obtaining main header!\n"); + return NULL; + } + ShowError("Map cache is corrupted!\r"); // If the file is totally corrupted this will allow us to warn the user + if( GetULong((unsigned char *)&(header.file_size)) != size ) { + ShowError("map_init_mapcache: Map cache is corrupted!\n"); + return NULL; + } + return buffer; } -- cgit v1.2.3-70-g09d2