Core/PacketIO: Fixed crash happening when someone sends too small packet that is processed directly in WorldSocket

This commit is contained in:
Aokromes
2016-07-07 20:25:29 +02:00
parent 02784be121
commit 4fc5672a60

View File

@@ -351,9 +351,20 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
switch (opcode)
{
case CMSG_PING:
{
LogOpcodeText(opcode, sessionGuard);
return HandlePing(packet) ? ReadDataHandlerResult::Ok : ReadDataHandlerResult::Error;
try
{
return HandlePing(packet) ? ReadDataHandlerResult::Ok : ReadDataHandlerResult::Error;
}
catch (ByteBufferPositionException const&)
{
}
TC_LOG_ERROR("network", "WorldSocket::ReadDataHandler(): client %s sent malformed CMSG_PING", GetRemoteIpAddress().to_string().c_str());
return ReadDataHandlerResult::Error;
}
case CMSG_AUTH_SESSION:
{
LogOpcodeText(opcode, sessionGuard);
if (_worldSession)
{
@@ -363,8 +374,17 @@ WorldSocket::ReadDataHandlerResult WorldSocket::ReadDataHandler()
return ReadDataHandlerResult::Error;
}
HandleAuthSession(packet);
return ReadDataHandlerResult::WaitingForQuery;
try
{
HandleAuthSession(packet);
return ReadDataHandlerResult::WaitingForQuery;
}
catch (ByteBufferPositionException const&)
{
}
TC_LOG_ERROR("network", "WorldSocket::ReadDataHandler(): client %s sent malformed CMSG_AUTH_SESSION", GetRemoteIpAddress().to_string().c_str());
return ReadDataHandlerResult::Error;
}
case CMSG_KEEP_ALIVE:
LogOpcodeText(opcode, sessionGuard);
sScriptMgr->OnPacketReceive(_worldSession, packet);