[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:
@@ -38,8 +38,6 @@
|
||||
//void called when player click on auctioneer npc
|
||||
void WorldSession::HandleAuctionHelloOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8);
|
||||
|
||||
uint64 guid; //NPC guid
|
||||
recv_data >> guid;
|
||||
|
||||
@@ -159,8 +157,6 @@ void WorldSession::SendAuctionCancelledToBidderMail( AuctionEntry* auction )
|
||||
//this void creates new auction and adds auction to some auctionhouse
|
||||
void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+8+4+4+4);
|
||||
|
||||
uint64 auctioneer, item;
|
||||
uint32 etime, bid, buyout;
|
||||
recv_data >> auctioneer >> item;
|
||||
@@ -286,8 +282,6 @@ void WorldSession::HandleAuctionSellItem( WorldPacket & recv_data )
|
||||
//this function is called when client bids or buys out auction
|
||||
void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+4+4);
|
||||
|
||||
uint64 auctioneer;
|
||||
uint32 auctionId;
|
||||
uint32 price;
|
||||
@@ -415,8 +409,6 @@ void WorldSession::HandleAuctionPlaceBid( WorldPacket & recv_data )
|
||||
//this void is called when auction_owner cancels his auction
|
||||
void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+4);
|
||||
|
||||
uint64 auctioneer;
|
||||
uint32 auctionId;
|
||||
recv_data >> auctioneer;
|
||||
@@ -493,8 +485,6 @@ void WorldSession::HandleAuctionRemoveItem( WorldPacket & recv_data )
|
||||
//called when player lists his bids
|
||||
void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+4+4);
|
||||
|
||||
uint64 guid; //NPC guid
|
||||
uint32 listfrom; //page of auctions
|
||||
uint32 outbiddedCount; //count of outbidded auctions
|
||||
@@ -549,8 +539,6 @@ void WorldSession::HandleAuctionListBidderItems( WorldPacket & recv_data )
|
||||
//this void sends player info about his auctions
|
||||
void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+4);
|
||||
|
||||
uint32 listfrom;
|
||||
uint64 guid;
|
||||
|
||||
@@ -586,8 +574,6 @@ void WorldSession::HandleAuctionListOwnerItems( WorldPacket & recv_data )
|
||||
//this void is called when player clicks on search button
|
||||
void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
|
||||
{
|
||||
CHECK_PACKET_SIZE(recv_data,8+4+1+1+1+4+4+4+4+1);
|
||||
|
||||
std::string searchedname;
|
||||
uint8 levelmin, levelmax, usable;
|
||||
uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality;
|
||||
@@ -597,9 +583,6 @@ void WorldSession::HandleAuctionListItems( WorldPacket & recv_data )
|
||||
recv_data >> listfrom; // start, used for page control listing by 50 elements
|
||||
recv_data >> searchedname;
|
||||
|
||||
// recheck with known string size
|
||||
CHECK_PACKET_SIZE(recv_data,8+4+(searchedname.size()+1)+1+1+4+4+4+4+1);
|
||||
|
||||
recv_data >> levelmin >> levelmax;
|
||||
recv_data >> auctionSlotID >> auctionMainCategory >> auctionSubCategory;
|
||||
recv_data >> quality >> usable;
|
||||
|
||||
Reference in New Issue
Block a user