mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 01:37:01 +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
|
|
@ -31,8 +31,6 @@
|
|||
|
||||
void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, 8+2+2+8);
|
||||
|
||||
uint64 guid1;
|
||||
uint32 data;
|
||||
uint64 guid2;
|
||||
|
|
@ -265,8 +263,6 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::HandlePetNameQuery( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,4+8);
|
||||
|
||||
sLog.outDetail( "HandlePetNameQuery. CMSG_PET_NAME_QUERY" );
|
||||
|
||||
uint32 petnumber;
|
||||
|
|
@ -305,8 +301,6 @@ void WorldSession::SendPetNameQuery( uint64 petguid, uint32 petnumber)
|
|||
|
||||
void WorldSession::HandlePetSetAction( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, 8+4+2+2);
|
||||
|
||||
sLog.outDetail( "HandlePetSetAction. CMSG_PET_SET_ACTION" );
|
||||
|
||||
uint64 petguid;
|
||||
|
|
@ -379,8 +373,6 @@ void WorldSession::HandlePetSetAction( WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::HandlePetRename( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, 8+1);
|
||||
|
||||
sLog.outDetail( "HandlePetRename. CMSG_PET_RENAME" );
|
||||
|
||||
uint64 petguid;
|
||||
|
|
@ -391,7 +383,6 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data )
|
|||
|
||||
recv_data >> petguid;
|
||||
recv_data >> name;
|
||||
CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
|
||||
recv_data >> isdeclined;
|
||||
|
||||
Pet* pet = ObjectAccessor::GetPet(petguid);
|
||||
|
|
@ -426,7 +417,6 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data )
|
|||
{
|
||||
for(int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, recv_data.rpos() + 1);
|
||||
recv_data >> declinedname.name[i];
|
||||
}
|
||||
|
||||
|
|
@ -458,8 +448,6 @@ void WorldSession::HandlePetRename( WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::HandlePetAbandon( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, 8);
|
||||
|
||||
uint64 guid;
|
||||
recv_data >> guid; //pet guid
|
||||
sLog.outDetail( "HandlePetAbandon. CMSG_PET_ABANDON pet guid is %u", GUID_LOPART(guid) );
|
||||
|
|
@ -490,8 +478,6 @@ void WorldSession::HandlePetAbandon( WorldPacket & recv_data )
|
|||
|
||||
void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
CHECK_PACKET_SIZE(recvPacket,8);
|
||||
|
||||
sLog.outDetail("CMSG_PET_UNLEARN");
|
||||
uint64 guid;
|
||||
recvPacket >> guid; // Pet guid
|
||||
|
|
@ -519,8 +505,6 @@ void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket)
|
|||
|
||||
void WorldSession::HandlePetSpellAutocastOpcode( WorldPacket& recvPacket )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recvPacket,8+2+2+1);
|
||||
|
||||
sLog.outDetail("CMSG_PET_SPELL_AUTOCAST");
|
||||
uint64 guid;
|
||||
uint32 spellid;
|
||||
|
|
@ -565,7 +549,6 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket )
|
|||
{
|
||||
sLog.outDetail("WORLD: CMSG_PET_CAST_SPELL");
|
||||
|
||||
CHECK_PACKET_SIZE(recvPacket,8+1+4+1);
|
||||
uint64 guid;
|
||||
uint32 spellid;
|
||||
uint8 cast_count;
|
||||
|
|
@ -660,8 +643,6 @@ void WorldSession::HandlePetLearnTalent( WorldPacket & recv_data )
|
|||
{
|
||||
sLog.outDebug("WORLD: CMSG_PET_LEARN_TALENT");
|
||||
|
||||
CHECK_PACKET_SIZE(recv_data, 8+4+4);
|
||||
|
||||
uint64 guid;
|
||||
uint32 talent_id, requested_rank;
|
||||
recv_data >> guid >> talent_id >> requested_rank;
|
||||
|
|
@ -674,8 +655,6 @@ void WorldSession::HandleLearnPreviewTalentsPet( WorldPacket & recv_data )
|
|||
{
|
||||
sLog.outDebug("CMSG_LEARN_PREVIEW_TALENTS_PET");
|
||||
|
||||
CHECK_PACKET_SIZE(recv_data, 8+4);
|
||||
|
||||
uint64 guid;
|
||||
recv_data >> guid;
|
||||
|
||||
|
|
@ -686,8 +665,6 @@ void WorldSession::HandleLearnPreviewTalentsPet( WorldPacket & recv_data )
|
|||
|
||||
for(uint32 i = 0; i < talentsCount; ++i)
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data, recv_data.rpos()+4+4);
|
||||
|
||||
recv_data >> talentId >> talentRank;
|
||||
|
||||
_player->LearnPetTalent(guid, talentId, talentRank);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue