summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c14
1 files changed, 14 insertions, 0 deletions
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;
}