Browse Source

Validate spell IDs that are sent over the network

pull/4932/head
staphen 4 years ago committed by Anders Jenbo
parent
commit
156343d44b
  1. 16
      Source/msg.cpp

16
Source/msg.cpp

@ -1036,6 +1036,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.").c_str(), player._pName);
return sizeof(message);
}
if (currlevel == 0 && !spelldata[spell].sTownSpell) {
LogError(_("{:s} has cast an illegal spell.").c_str(), player._pName);
return sizeof(message);
@ -1071,6 +1075,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.").c_str(), player._pName);
return sizeof(message);
}
if (currlevel == 0 && !spelldata[spell].sTownSpell) {
LogError(_("{:s} has cast an illegal spell.").c_str(), player._pName);
return sizeof(message);
@ -1229,6 +1237,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.").c_str(), player._pName);
return sizeof(message);
}
if (currlevel == 0 && !spelldata[spell].sTownSpell) {
LogError(_("{:s} has cast an illegal spell.").c_str(), player._pName);
return sizeof(message);
@ -1261,6 +1273,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.").c_str(), player._pName);
return sizeof(message);
}
if (currlevel == 0 && !spelldata[spell].sTownSpell) {
LogError(_("{:s} has cast an illegal spell.").c_str(), player._pName);
return sizeof(message);

Loading…
Cancel
Save