[8378] Use exceptions instead of explicit size checking for each packet

CHECK_PACKET_SIZE was pretty error prone; once it was forgotten mangosd
could crash due to the asserts in ByteBuffer.h. That was exploitable by
malicious players.
Furthermore, there were duplicate checks: Additionally to
CHECK_PACKET_SIZE, the ByteBuffer assertions keept an eye
on not exceeding the packet boundaries - just to crash the server for
sure in such a case.
To prevent memory leaks or other undesirable states, please read in
every handler all variables _before_ doing any concrete handling.
This commit is contained in:
arrai 2009-08-15 22:06:35 +02:00
parent c26c7395a1
commit a24f39a36f
32 changed files with 129 additions and 741 deletions

View file

@ -34,8 +34,6 @@
void WorldSession::HandleBattlemasterHelloOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data, 8);
uint64 guid;
recv_data >> guid;
sLog.outDebug( "WORLD: Recvd CMSG_BATTLEMASTER_HELLO Message from (GUID: %u TypeId:%u)", GUID_LOPART(guid),GuidHigh2TypeId(GUID_HIPART(guid)));
@ -71,8 +69,6 @@ void WorldSession::SendBattlegGroundList( uint64 guid, BattleGroundTypeId bgType
void WorldSession::HandleBattlemasterJoinOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data, 8+4+4+1);
uint64 guid;
uint32 bgTypeId_;
uint32 instanceId;
@ -275,8 +271,6 @@ void WorldSession::HandlePVPLogDataOpcode( WorldPacket & /*recv_data*/ )
void WorldSession::HandleBattlefieldListOpcode( WorldPacket &recv_data )
{
CHECK_PACKET_SIZE(recv_data, 4 + 1);
sLog.outDebug( "WORLD: Recvd CMSG_BATTLEFIELD_LIST Message");
uint32 bgTypeId;
@ -299,8 +293,6 @@ void WorldSession::HandleBattlefieldListOpcode( WorldPacket &recv_data )
void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
{
CHECK_PACKET_SIZE(recv_data, 1+1+4+2+1);
sLog.outDebug( "WORLD: Recvd CMSG_BATTLEFIELD_PORT Message");
uint8 type; // arenatype if arena
@ -495,8 +487,6 @@ void WorldSession::HandleBattleFieldPortOpcode( WorldPacket &recv_data )
void WorldSession::HandleLeaveBattlefieldOpcode( WorldPacket & /*recv_data*/ )
{
//CHECK_PACKET_SIZE(recv_data, 1+1+4+2);
sLog.outDebug( "WORLD: Recvd CMSG_LEAVE_BATTLEFIELD Message");
//uint8 unk1, unk2;
@ -579,8 +569,6 @@ void WorldSession::HandleAreaSpiritHealerQueryOpcode( WorldPacket & recv_data )
{
sLog.outDebug("WORLD: CMSG_AREA_SPIRIT_HEALER_QUERY");
CHECK_PACKET_SIZE(recv_data, 8);
BattleGround *bg = _player->GetBattleGround();
if (!bg)
return;
@ -602,8 +590,6 @@ void WorldSession::HandleAreaSpiritHealerQueueOpcode( WorldPacket & recv_data )
{
sLog.outDebug("WORLD: CMSG_AREA_SPIRIT_HEALER_QUEUE");
CHECK_PACKET_SIZE(recv_data, 8);
BattleGround *bg = _player->GetBattleGround();
if (!bg)
return;
@ -623,8 +609,6 @@ void WorldSession::HandleAreaSpiritHealerQueueOpcode( WorldPacket & recv_data )
void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data, 8+1+1+1);
sLog.outDebug("WORLD: CMSG_BATTLEMASTER_JOIN_ARENA");
recv_data.hexlike();
@ -778,8 +762,6 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
void WorldSession::HandleReportPvPAFK( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data, 8);
uint64 playerGuid;
recv_data >> playerGuid;
Player *reportedPlayer = objmgr.GetPlayer(playerGuid);