mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 02:04:52 +01:00
[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:
@@ -35,8 +35,6 @@
|
||||
void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
// TODO: add targets.read() check
|
||||
CHECK_PACKET_SIZE(recvPacket,1+1+1+4+8+4+1);
|
||||
|
||||
Player* pUser = _player;
|
||||
|
||||
// ignore for remote control state
|
||||
@@ -162,8 +160,6 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
|
||||
|
||||
void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
CHECK_PACKET_SIZE(recvPacket,1+1);
|
||||
|
||||
sLog.outDetail("WORLD: CMSG_OPEN_ITEM packet, data length = %i",(uint32)recvPacket.size());
|
||||
|
||||
Player* pUser = _player;
|
||||
@@ -242,8 +238,6 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
||||
|
||||
void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, 8);
|
||||
|
||||
uint64 guid;
|
||||
|
||||
recv_data >> guid;
|
||||
@@ -267,8 +261,6 @@ void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data )
|
||||
|
||||
void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket)
|
||||
{
|
||||
CHECK_PACKET_SIZE(recvPacket,8);
|
||||
|
||||
uint64 guid;
|
||||
recvPacket >> guid;
|
||||
|
||||
@@ -290,8 +282,6 @@ void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket)
|
||||
|
||||
void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
CHECK_PACKET_SIZE(recvPacket,1+4+1);
|
||||
|
||||
uint32 spellId;
|
||||
uint8 cast_count, unk_flags;
|
||||
recvPacket >> cast_count;
|
||||
@@ -365,8 +355,6 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
||||
|
||||
void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
CHECK_PACKET_SIZE(recvPacket,5);
|
||||
|
||||
// increments with every CANCEL packet, don't use for now
|
||||
uint8 counter;
|
||||
uint32 spellId;
|
||||
@@ -379,8 +367,6 @@ void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket)
|
||||
|
||||
void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket)
|
||||
{
|
||||
CHECK_PACKET_SIZE(recvPacket,4);
|
||||
|
||||
uint32 spellId;
|
||||
recvPacket >> spellId;
|
||||
|
||||
@@ -408,8 +394,6 @@ void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket)
|
||||
|
||||
void WorldSession::HandlePetCancelAuraOpcode( WorldPacket& recvPacket)
|
||||
{
|
||||
CHECK_PACKET_SIZE(recvPacket, 8+4);
|
||||
|
||||
uint64 guid;
|
||||
uint32 spellId;
|
||||
|
||||
@@ -464,8 +448,6 @@ void WorldSession::HandleCancelAutoRepeatSpellOpcode( WorldPacket& /*recvPacket*
|
||||
void WorldSession::HandleCancelChanneling( WorldPacket & /*recv_data */)
|
||||
{
|
||||
/*
|
||||
CHECK_PACKET_SIZE(recv_data, 4);
|
||||
|
||||
uint32 spellid;
|
||||
recv_data >> spellid;
|
||||
*/
|
||||
@@ -473,8 +455,6 @@ void WorldSession::HandleCancelChanneling( WorldPacket & /*recv_data */)
|
||||
|
||||
void WorldSession::HandleTotemDestroyed( WorldPacket& recvPacket)
|
||||
{
|
||||
CHECK_PACKET_SIZE(recvPacket, 1);
|
||||
|
||||
// ignore for remote control state
|
||||
if(_player->m_mover != _player)
|
||||
return;
|
||||
@@ -512,8 +492,6 @@ void WorldSession::HandleSelfResOpcode( WorldPacket & /*recv_data*/ )
|
||||
|
||||
void WorldSession::HandleSpellClick( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, 8);
|
||||
|
||||
uint64 guid;
|
||||
recv_data >> guid;
|
||||
|
||||
@@ -541,7 +519,6 @@ void WorldSession::HandleSpellClick( WorldPacket & recv_data )
|
||||
void WorldSession::HandleMirrrorImageDataRequest( WorldPacket & recv_data )
|
||||
{
|
||||
sLog.outDebug("WORLD: CMSG_GET_MIRRORIMAGE_DATA");
|
||||
CHECK_PACKET_SIZE(recv_data, 8);
|
||||
uint64 guid;
|
||||
recv_data >> guid;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user