diff options
author | Shauren <shauren.trinity@gmail.com> | 2017-01-17 20:14:44 +0100 |
---|---|---|
committer | ariel- <ariel-@users.noreply.github.com> | 2017-01-21 21:10:46 -0300 |
commit | 742c5f1e0b4690ef7ab3923e406b2599ea01b985 (patch) | |
tree | 3b3349bc2cff85c70c660f3dc4d61c587f66a0f8 /src/common/Collision/Management/MMapManager.cpp | |
parent | 60d1c0e20d3f8f32de81bff047531b927e586a97 (diff) |
Fix static analysis issues
CID 1291964
CID 1292775
(cherry picked from commit 6767bbc95f46df4b62c8131a39a132d3f9bb8a26)
Conflicts:
src/server/game/Entities/Player/Player.cpp
src/server/game/Spells/SpellHistory.h
src/server/game/Spells/SpellInfo.cpp
Diffstat (limited to 'src/common/Collision/Management/MMapManager.cpp')
-rw-r--r-- | src/common/Collision/Management/MMapManager.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/common/Collision/Management/MMapManager.cpp b/src/common/Collision/Management/MMapManager.cpp index e5f503bf70a..cec5c0da7f0 100644 --- a/src/common/Collision/Management/MMapManager.cpp +++ b/src/common/Collision/Management/MMapManager.cpp @@ -154,6 +154,17 @@ namespace MMAP return false; } + long pos = ftell(file); + fseek(file, 0, SEEK_END); + if (static_cast<int32>(fileHeader.size) > ftell(file) - pos) + { + TC_LOG_ERROR("maps", "MMAP:loadMap: %03u%02i%02i.mmtile has corrupted data size", mapId, x, y); + fclose(file); + return false; + } + + fseek(file, pos, SEEK_SET); + unsigned char* data = (unsigned char*)dtAlloc(fileHeader.size, DT_ALLOC_PERM); ASSERT(data); |