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

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.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-19 16:26:22 -05:00
parent d9ed49749d
commit e954904e6d
30 changed files with 128 additions and 739 deletions

View File

@@ -36,8 +36,6 @@
void WorldSession::HandleQuestgiverStatusQueryOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8);
uint64 guid;
recv_data >> guid;
uint8 questStatus = DIALOG_STATUS_NONE;
@@ -84,8 +82,6 @@ void WorldSession::HandleQuestgiverStatusQueryOpcode( WorldPacket & recv_data )
void WorldSession::HandleQuestgiverHelloOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8);
uint64 guid;
recv_data >> guid;
@@ -114,8 +110,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;
@@ -211,8 +205,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;
@@ -236,8 +228,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 );
@@ -251,8 +241,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;
@@ -309,8 +297,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;
@@ -343,8 +329,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;
@@ -358,8 +342,6 @@ void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data )
void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data)
{
CHECK_PACKET_SIZE(recv_data,1);
uint8 slot;
recv_data >> slot;
@@ -383,8 +365,6 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data)
void WorldSession::HandleQuestConfirmAccept(WorldPacket& recv_data)
{
CHECK_PACKET_SIZE(recv_data,4);
uint32 quest;
recv_data >> quest;
@@ -393,8 +373,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;
@@ -437,8 +415,6 @@ void WorldSession::HandleQuestgiverQuestAutoLaunch(WorldPacket& /*recvPacket*/)
void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
{
CHECK_PACKET_SIZE(recvPacket,4);
uint32 questId;
recvPacket >> questId;
@@ -496,8 +472,6 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket)
void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket)
{
CHECK_PACKET_SIZE(recvPacket,8+1);
uint64 guid;
uint8 msg;
recvPacket >> guid >> msg;