[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

@ -32,8 +32,6 @@
void WorldSession::HandleQuestgiverStatusQueryOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8);
uint64 guid;
recv_data >> guid;
uint8 questStatus = DIALOG_STATUS_NONE;
@ -80,8 +78,6 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode( WorldPacket & recv_data )
void WorldSession::HandleQuestgiverHelloOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8);
uint64 guid;
recv_data >> guid;
@ -110,8 +106,6 @@ void WorldSession::HandleQuestgiverHelloOpcode( WorldPacket & recv_data )
void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data, 8+4+4);
uint64 guid;
uint32 quest;
uint32 unk1;
@ -207,8 +201,6 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode( WorldPacket & recv_data )
void WorldSession::HandleQuestgiverQueryQuestOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data, 8+4+1);
uint64 guid;
uint32 quest;
uint8 unk1;
@ -232,8 +224,6 @@ void WorldSession::HandleQuestgiverQueryQuestOpcode( WorldPacket & recv_data )
void WorldSession::HandleQuestQueryOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data, 4);
uint32 quest;
recv_data >> quest;
sLog.outDebug( "WORLD: Received CMSG_QUEST_QUERY quest = %u",quest );
@ -247,8 +237,6 @@ void WorldSession::HandleQuestQueryOpcode( WorldPacket & recv_data )
void WorldSession::HandleQuestgiverChooseRewardOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8+4+4);
uint32 quest, reward;
uint64 guid;
recv_data >> guid >> quest >> reward;
@ -305,8 +293,6 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode( WorldPacket & recv_data )
void WorldSession::HandleQuestgiverRequestRewardOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8+4);
uint32 quest;
uint64 guid;
recv_data >> guid >> quest;
@ -339,8 +325,6 @@ void WorldSession::HandleQuestgiverCancel(WorldPacket& /*recv_data*/ )
void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data )
{
CHECK_PACKET_SIZE(recv_data,1+1);
uint8 slot1, slot2;
recv_data >> slot1 >> slot2;
@ -354,8 +338,6 @@ void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data )
void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data)
{
CHECK_PACKET_SIZE(recv_data,1);
uint8 slot;
recv_data >> slot;
@ -379,8 +361,6 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data)
void WorldSession::HandleQuestConfirmAccept(WorldPacket& recv_data)
{
CHECK_PACKET_SIZE(recv_data,4);
uint32 quest;
recv_data >> quest;
@ -389,8 +369,6 @@ void WorldSession::HandleQuestConfirmAccept(WorldPacket& recv_data)
void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recv_data)
{
CHECK_PACKET_SIZE(recv_data,8+4);
uint32 quest;
uint64 guid;
recv_data >> guid >> quest;
@ -427,8 +405,6 @@ void WorldSession::HandleQuestgiverQuestAutoLaunch(WorldPacket& /*recvPacket*/)
void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
{
CHECK_PACKET_SIZE(recvPacket,4);
uint32 questId;
recvPacket >> questId;
@ -486,8 +462,6 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket)
{
CHECK_PACKET_SIZE(recvPacket,8+1);
uint64 guid;
uint8 msg;
recvPacket >> guid >> msg;