refactor(HandleAuctionListOwnerItems): prevent crash (#2684)

This commit is contained in:
Stefano Borzì
2020-02-24 08:40:02 +01:00
committed by GitHub
parent ed243d6911
commit 9e307455a8
4 changed files with 16 additions and 14 deletions

View File

@@ -218,7 +218,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recvData)
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, ERR_AUCTION_DATABASE_ERROR);
return;
}
// check if there are 2 identical guids, in this case user is most likely cheating
for (uint32 i = 0; i < itemsCount - 1; ++i)
{
@@ -646,6 +646,13 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket & recvData)
//this void sends player info about his auctions
void WorldSession::HandleAuctionListOwnerItems(WorldPacket & recvData)
{
// prevent crash caused by malformed packet
uint64 guid;
uint32 listfrom;
recvData >> guid;
recvData >> listfrom;
// pussywizard:
const uint32 delay = 4500;
const uint32 now = World::GetGameTimeMS();
@@ -656,10 +663,11 @@ void WorldSession::HandleAuctionListOwnerItems(WorldPacket & recvData)
diff = delay;
_lastAuctionListOwnerItemsMSTime = now + delay; // set longest possible here, actual exectuing will change this to getMSTime of that moment
_player->m_Events.AddEvent(new AuctionListOwnerItemsDelayEvent(recvData, _player->GetGUID(), true), _player->m_Events.CalculateTime(delay-diff));
_player->m_Events.AddEvent(new AuctionListOwnerItemsDelayEvent(guid, _player->GetGUID(), true), _player->m_Events.CalculateTime(delay-diff));
}
void WorldSession::HandleAuctionListOwnerItemsEvent(WorldPacket & recvData)
void WorldSession::HandleAuctionListOwnerItemsEvent(uint64 creatureGuid)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_AUCTION_LIST_OWNER_ITEMS");
@@ -667,13 +675,7 @@ void WorldSession::HandleAuctionListOwnerItemsEvent(WorldPacket & recvData)
_lastAuctionListOwnerItemsMSTime = World::GetGameTimeMS(); // pussywizard
uint32 listfrom;
uint64 guid;
recvData >> guid;
recvData >> listfrom; // not used in fact (this list not have page control in client)
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER);
Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(creatureGuid, UNIT_NPC_FLAG_AUCTIONEER);
if (!creature)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)