[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 committed 2009-08-19 16:26:22 -05:00
1 parent d9ed49749d
commit e954904e6d
30 files changed
+128 -739

No files matched your search

-13
View File
@@ -31,12 +31,8 @@
#include "WaypointMovementGenerator.h"
#include "DestinationHolderImp.h"
#include <cassert>
void WorldSession::HandleTaxiNodeStatusQueryOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8);
sLog.outDebug( "WORLD: Received CMSG_TAXINODE_STATUS_QUERY" );
uint64 guid;
@@ -72,8 +68,6 @@ void WorldSession::SendTaxiStatus( uint64 guid )
void WorldSession::HandleTaxiQueryAvailableNodes( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8);
sLog.outDebug( "WORLD: Received CMSG_TAXIQUERYAVAILABLENODES" );
uint64 guid;
@@ -160,8 +154,6 @@ bool WorldSession::SendLearnNewTaxiNode( Creature* unit )
void WorldSession::HandleActivateTaxiExpressOpcode ( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8+4+4);
sLog.outDebug( "WORLD: Received CMSG_ACTIVATETAXIEXPRESS" );
uint64 guid;
@@ -175,9 +167,6 @@ void WorldSession::HandleActivateTaxiExpressOpcode ( WorldPacket & recv_data )
sLog.outDebug( "WORLD: HandleActivateTaxiExpressOpcode - Unit (GUID: %u) not found or you can't interact with it.", uint32(GUID_LOPART(guid)) );
return;
}
// recheck
CHECK_PACKET_SIZE(recv_data,8+4+4+node_count*4);
std::vector<uint32> nodes;
for(uint32 i = 0; i < node_count; ++i)
@@ -264,8 +253,6 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& /*recv_data*/)
void WorldSession::HandleActivateTaxiOpcode( WorldPacket & recv_data )
{
CHECK_PACKET_SIZE(recv_data,8+4+4);
sLog.outDebug( "WORLD: Received CMSG_ACTIVATETAXI" );
uint64 guid;