Core/Entities: Fix exploit/crash in inventory-handling (CMSG_OPEN_ITEM) -thanks to leak

(Adds a scrutiny-based check to baghandling: don't allow placing items in bags that are not "usable" as regular bags)

--HG--
branch : trunk
This commit is contained in:
click
2010-11-07 20:08:52 +01:00
parent 044c003bdd
commit 5d4f009a87
2 changed files with 12 additions and 4 deletions
+3 -4
View File
@@ -11990,10 +11990,9 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update)
if (pItem)
{
sLog.outDebug("STORAGE: DestroyItem bag = %u, slot = %u, item = %u", bag, slot, pItem->GetEntry());
// start from destroy contained items (only equipped bag can have its)
if (pItem->IsBag() && pItem->IsEquipped()) // this also prevent infinity loop if empty bag stored in bag == slot
{
// Also remove all contained items if the item is a bag.
// This if() prevents item saving crashes if the condition for a bag to be empty before being destroyed was bypassed somehow.
if (pItem->IsBag() && !((Bag*)pItem)->IsEmpty()) {
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
DestroyItem(slot, i, update);
}
@@ -221,6 +221,15 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
return;
}
// Verify that the bag is an actual bag that can be used "normally"
if(!(proto->Flags & ITEM_PROTO_FLAG_OPENABLE))
{
pUser->SendEquipError(EQUIP_ERR_CANT_DO_RIGHT_NOW, pItem, NULL);
sLog.outError("Possible hacking attempt: Player %s [guid: %u] tried to open item [guid: %u, entry: %u] which is not openable!",
pUser->GetName(), pUser->GetGUIDLow(), pItem->GetGUIDLow(), proto->ItemId);
return;
}
// locked item
uint32 lockId = proto->LockID;
if (lockId)