Core/Misc: Prevent crashing server with CMSG_TIME_SYNC_RESP and fixed some warnings

This commit is contained in:
Intel
2014-12-28 21:57:14 +02:00
parent 5c3762e1ee
commit 43fdf4cada
2 changed files with 9 additions and 2 deletions

View File

@@ -248,7 +248,7 @@ inline void LoadDBC(uint32& availableDbcLocales, StoreProblemList& errors, DBCSt
// compatibility format and C++ structure sizes
ASSERT(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T),
"Size of '%s' set by format string (%u) not equal size of C++ structure (%u).",
filename.c_str(), DBCFileLoader::GetFormatRecordSize(storage.GetFormat()), sizeof(T));
filename.c_str(), DBCFileLoader::GetFormatRecordSize(storage.GetFormat()), uint32(sizeof(T)));
++DBCFileCount;
std::string dbcFilename = dbcPath + filename;
@@ -296,7 +296,7 @@ inline void LoadGameTable(StoreProblemList& errors, std::string const& tableName
// compatibility format and C++ structure sizes
ASSERT(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T),
"Size of '%s' set by format string (%u) not equal size of C++ structure (%u).",
filename.c_str(), DBCFileLoader::GetFormatRecordSize(storage.GetFormat()), sizeof(T));
filename.c_str(), DBCFileLoader::GetFormatRecordSize(storage.GetFormat()), uint32(sizeof(T)));
++DBCFileCount;
std::string dbcFilename = dbcPath + filename;

View File

@@ -1498,6 +1498,13 @@ void WorldSession::HandleTimeSyncResp(WorldPackets::Misc::TimeSyncResponse& pack
{
TC_LOG_DEBUG("network", "CMSG_TIME_SYNC_RESP");
// Prevent crashing server if queue is empty
if (_player->m_timeSyncQueue.empty())
{
TC_LOG_ERROR("network", "Received CMSG_TIME_SYNC_RESP from player %s without requesting it (hacker?)", _player->GetName().c_str());
return;
}
if (packet.SequenceIndex != _player->m_timeSyncQueue.front())
TC_LOG_ERROR("network", "Wrong time sync counter from player %s (cheater?)", _player->GetName().c_str());