mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[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:
parent
c26c7395a1
commit
a24f39a36f
32 changed files with 129 additions and 741 deletions
|
|
@ -38,8 +38,6 @@
|
|||
|
||||
void WorldSession::HandleTabardVendorActivateOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8);
|
||||
|
||||
uint64 guid;
|
||||
recv_data >> guid;
|
||||
|
||||
|
|
@ -66,8 +64,6 @@ void WorldSession::SendTabardVendorActivate( uint64 guid )
|
|||
|
||||
void WorldSession::HandleBankerActivateOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8);
|
||||
|
||||
uint64 guid;
|
||||
|
||||
sLog.outDebug( "WORLD: Received CMSG_BANKER_ACTIVATE" );
|
||||
|
|
@ -97,8 +93,6 @@ void WorldSession::SendShowBank( uint64 guid )
|
|||
|
||||
void WorldSession::HandleTrainerListOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8);
|
||||
|
||||
uint64 guid;
|
||||
|
||||
recv_data >> guid;
|
||||
|
|
@ -194,8 +188,6 @@ void WorldSession::SendTrainerList( uint64 guid, const std::string& strTitle )
|
|||
|
||||
void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+4);
|
||||
|
||||
uint64 guid;
|
||||
uint32 spellId = 0;
|
||||
|
||||
|
|
@ -261,8 +253,6 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::HandleGossipHelloOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8);
|
||||
|
||||
sLog.outDebug( "WORLD: Received CMSG_GOSSIP_HELLO" );
|
||||
|
||||
uint64 guid;
|
||||
|
|
@ -306,8 +296,6 @@ void WorldSession::HandleGossipHelloOpcode( WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+4+4);
|
||||
|
||||
sLog.outDebug("WORLD: CMSG_GOSSIP_SELECT_OPTION");
|
||||
|
||||
uint32 option;
|
||||
|
|
@ -319,8 +307,6 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data )
|
|||
|
||||
if(_player->PlayerTalkClass->GossipOptionCoded( option ))
|
||||
{
|
||||
// recheck
|
||||
CHECK_PACKET_SIZE(recv_data,8+4+1);
|
||||
sLog.outBasic("reading string");
|
||||
recv_data >> code;
|
||||
sLog.outBasic("string read: %s", code.c_str());
|
||||
|
|
@ -351,8 +337,6 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::HandleSpiritHealerActivateOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8);
|
||||
|
||||
sLog.outDebug("WORLD: CMSG_SPIRIT_HEALER_ACTIVATE");
|
||||
|
||||
uint64 guid;
|
||||
|
|
@ -410,8 +394,6 @@ void WorldSession::SendSpiritResurrect()
|
|||
|
||||
void WorldSession::HandleBinderActivateOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8);
|
||||
|
||||
uint64 npcGUID;
|
||||
recv_data >> npcGUID;
|
||||
|
||||
|
|
@ -483,8 +465,6 @@ void WorldSession::SendBindPoint(Creature *npc)
|
|||
|
||||
void WorldSession::HandleListStabledPetsOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8);
|
||||
|
||||
sLog.outDebug("WORLD: Recv MSG_LIST_STABLED_PETS");
|
||||
uint64 npcGUID;
|
||||
|
||||
|
|
@ -559,8 +539,6 @@ void WorldSession::SendStablePet(uint64 guid )
|
|||
|
||||
void WorldSession::HandleStablePet( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, 8);
|
||||
|
||||
sLog.outDebug("WORLD: Recv CMSG_STABLE_PET");
|
||||
uint64 npcGUID;
|
||||
|
||||
|
|
@ -628,8 +606,6 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::HandleUnstablePet( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, 8+4);
|
||||
|
||||
sLog.outDebug("WORLD: Recv CMSG_UNSTABLE_PET.");
|
||||
uint64 npcGUID;
|
||||
uint32 petnumber;
|
||||
|
|
@ -708,8 +684,6 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, 8);
|
||||
|
||||
sLog.outDebug("WORLD: Recv CMSG_BUY_STABLE_SLOT.");
|
||||
uint64 npcGUID;
|
||||
|
||||
|
|
@ -753,8 +727,6 @@ void WorldSession::HandleStableRevivePet( WorldPacket &/* recv_data */)
|
|||
|
||||
void WorldSession::HandleStableSwapPet( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, 8+4);
|
||||
|
||||
sLog.outDebug("WORLD: Recv CMSG_STABLE_SWAP_PET.");
|
||||
uint64 npcGUID;
|
||||
uint32 pet_number;
|
||||
|
|
@ -826,8 +798,6 @@ void WorldSession::HandleStableSwapPet( WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::HandleRepairItemOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, 8+8+1);
|
||||
|
||||
sLog.outDebug("WORLD: CMSG_REPAIR_ITEM");
|
||||
|
||||
uint64 npcGUID, itemGUID;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue