Core/Spells: Do not allow adding USE-enhancements on items that already has a Use: spell. Fixes a possible exploit (original fix by Leak)

(Cleaned up to adhere to codingstandards)
Closes issue 4185.

--HG--
branch : trunk
This commit is contained in:
click
2010-09-27 05:41:13 +02:00
parent ee705bba32
commit 88420cdcd1
+19
View File
@@ -3424,6 +3424,25 @@ void Spell::EffectEnchantItemPerm(SpellEffIndex effIndex)
if (!pEnchant) if (!pEnchant)
return; return;
// Prevent applying enchanements with Use: spell on items that already have a Use: effect, this is usually blocked from client side and
// can only be bypassed with memory manipulation.
for (int s = 0; s < 3; ++s)
{
if (pEnchant->type[s] == ITEM_ENCHANTMENT_TYPE_USE_SPELL)
{
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
{
ItemPrototype const *proto = itemTarget->GetProto();
if (proto->Spells[i].SpellId && proto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE)
{
sLog.outError("Exploiting attempt: Player %s(GUID: %u) tried to apply an enchanement with Use: spell on an item that already has a Use: effect,"
" this should be blocked from client side.", p_caster->GetName(), p_caster->GetGUIDLow());
return;
}
}
}
}
// item can be in trade slot and have owner diff. from caster // item can be in trade slot and have owner diff. from caster
Player* item_owner = itemTarget->GetOwner(); Player* item_owner = itemTarget->GetOwner();
if (!item_owner) if (!item_owner)