Browse Source

Validate spell IDs that are sent over the network

pull/4922/head
staphen 4 years ago committed by Anders Jenbo
parent
commit
4a3a8f5a57
  1. 16
      Source/msg.cpp

16
Source/msg.cpp

@ -1126,6 +1126,10 @@ DWORD OnSpellWall(const TCmd *pCmd, Player &player)
return sizeof(message);
auto spell = static_cast<spell_id>(message.wParam1);
if (!IsValidSpell(spell)) {
LogError(_("{:s} has cast an invalid spell."), player._pName);
return sizeof(message);
}
if (leveltype == DTYPE_TOWN && !spelldata[spell].sTownSpell) {
LogError(_("{:s} has cast an illegal spell."), player._pName);
return sizeof(message);
@ -1161,6 +1165,10 @@ DWORD OnSpellTile(const TCmd *pCmd, Player &player)
return sizeof(message);
auto spell = static_cast<spell_id>(message.wParam1);
if (!IsValidSpell(spell)) {
LogError(_("{:s} has cast an invalid spell."), player._pName);
return sizeof(message);
}
if (leveltype == DTYPE_TOWN && !spelldata[spell].sTownSpell) {
LogError(_("{:s} has cast an illegal spell."), player._pName);
return sizeof(message);
@ -1319,6 +1327,10 @@ DWORD OnSpellMonster(const TCmd *pCmd, Player &player)
return sizeof(message);
auto spell = static_cast<spell_id>(message.wParam2);
if (!IsValidSpell(spell)) {
LogError(_("{:s} has cast an invalid spell."), player._pName);
return sizeof(message);
}
if (leveltype == DTYPE_TOWN && !spelldata[spell].sTownSpell) {
LogError(_("{:s} has cast an illegal spell."), player._pName);
return sizeof(message);
@ -1351,6 +1363,10 @@ DWORD OnSpellPlayer(const TCmd *pCmd, Player &player)
return sizeof(message);
auto spell = static_cast<spell_id>(message.wParam2);
if (!IsValidSpell(spell)) {
LogError(_("{:s} has cast an invalid spell."), player._pName);
return sizeof(message);
}
if (leveltype == DTYPE_TOWN && !spelldata[spell].sTownSpell) {
LogError(_("{:s} has cast an illegal spell."), player._pName);
return sizeof(message);

Loading…
Cancel
Save