[8091] Check bag size at item protos loading and item slots at invetory loading.

This is single not safe places in work with bag slots in current code.
This commit is contained in:
VladimirMangos 2009-06-29 12:47:40 +04:00 committed by tomrus88
parent fad9c4c0b3
commit 5a8640a69b
3 changed files with 8 additions and 2 deletions

View file

@ -1735,6 +1735,12 @@ void ObjectMgr::LoadItemPrototypes()
const_cast<ItemPrototype*>(proto)->Stackable = 1000;
}
if(proto->ContainerSlots > MAX_BAG_SIZE)
{
sLog.outErrorDb("Item (Entry: %u) has too large value in ContainerSlots (%u), replace by hardcoded limit (%u).",i,proto->ContainerSlots,MAX_BAG_SIZE);
const_cast<ItemPrototype*>(proto)->ContainerSlots = MAX_BAG_SIZE;
}
if(proto->StatsCount > MAX_ITEM_PROTO_STATS)
{
sLog.outErrorDb("Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).",i,proto->StatsCount,MAX_ITEM_PROTO_STATS);

View file

@ -14756,7 +14756,7 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
item->SetSlot(NULL_SLOT);
// the item is in a bag, find the bag
std::map<uint64, Bag*>::const_iterator itr = bagMap.find(bag_guid);
if(itr != bagMap.end())
if(itr != bagMap.end() && slot < itr->second->GetBagSize())
itr->second->StoreItem(slot, item, true );
else
success = false;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8090"
#define REVISION_NR "8091"
#endif // __REVISION_NR_H__