Merge pull request #4646 from elecyb/crash1

Core/PacketIO: Fix crash and exploit caused when client sends tampered m...
This commit is contained in:
Machiavelli
2012-01-07 03:58:42 -08:00
3 changed files with 15 additions and 16 deletions
@@ -21733,6 +21733,8 @@ void Player::SendInitialPacketsBeforeAddToMap()
// SMSG_PET_GUIDS // SMSG_PET_GUIDS
// SMSG_UPDATE_WORLD_STATE // SMSG_UPDATE_WORLD_STATE
// SMSG_POWER_UPDATE // SMSG_POWER_UPDATE
SetMover(this);
} }
void Player::SendInitialPacketsAfterAddToMap() void Player::SendInitialPacketsAfterAddToMap()
@@ -472,18 +472,7 @@ void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data)
if (GetPlayer()->IsInWorld()) if (GetPlayer()->IsInWorld())
{ {
if (Unit* mover = ObjectAccessor::GetUnit(*GetPlayer(), guid)) if (_player->m_mover->GetGUID() != guid)
{
GetPlayer()->SetMover(mover);
if (mover != GetPlayer() && mover->canFly())
{
WorldPacket data(SMSG_MOVE_SET_CAN_FLY, 12);
data.append(mover->GetPackGUID());
data << uint32(0);
SendPacket(&data);
}
}
else
{ {
sLog->outError("HandleSetActiveMoverOpcode: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, guid, GetLogNameForGuid(guid), GUID_ENPART(guid), _player->m_mover->GetGUID()); sLog->outError("HandleSetActiveMoverOpcode: incorrect mover guid: mover is " UI64FMTD " (%s - Entry: %u) and should be " UI64FMTD, guid, GetLogNameForGuid(guid), GUID_ENPART(guid), _player->m_mover->GetGUID());
GetPlayer()->SetMover(GetPlayer()); GetPlayer()->SetMover(GetPlayer());
@@ -3096,9 +3096,15 @@ void AuraEffect::HandleModPossess(AuraApplication const* aurApp, uint8 mode, boo
} }
if (apply) if (apply)
target->SetCharmedBy(caster, CHARM_TYPE_POSSESS, aurApp); {
if (target->SetCharmedBy(caster, CHARM_TYPE_POSSESS, aurApp))
caster->ToPlayer()->SetMover(target);
}
else else
{
target->RemoveCharmedBy(caster); target->RemoveCharmedBy(caster);
caster->ToPlayer()->SetMover(caster);
}
} }
// only one spell has this aura // only one spell has this aura
@@ -3126,11 +3132,13 @@ void AuraEffect::HandleModPossessPet(AuraApplication const* aurApp, uint8 mode,
if (caster->ToPlayer()->GetPet() != pet) if (caster->ToPlayer()->GetPet() != pet)
return; return;
pet->SetCharmedBy(caster, CHARM_TYPE_POSSESS, aurApp); if (pet->SetCharmedBy(caster, CHARM_TYPE_POSSESS, aurApp))
caster->ToPlayer()->SetMover(pet);
} }
else else
{ {
pet->RemoveCharmedBy(caster); pet->RemoveCharmedBy(caster);
caster->ToPlayer()->SetMover(caster);
if (!pet->IsWithinDistInMap(caster, pet->GetMap()->GetVisibilityRange())) if (!pet->IsWithinDistInMap(caster, pet->GetMap()->GetVisibilityRange()))
pet->Remove(PET_SAVE_NOT_IN_SLOT, true); pet->Remove(PET_SAVE_NOT_IN_SLOT, true);