diff options
author | jackpoz <giacomopoz@gmail.com> | 2015-01-31 22:59:21 +0100 |
---|---|---|
committer | Nayd <dnpd.dd@gmail.com> | 2015-01-31 22:24:12 +0000 |
commit | 4c0476bfd7d104386806e35edfa975634495dd2c (patch) | |
tree | 5a3f4dda880d265ef90d7401445cd2fd369c78e4 /src/server/game/Globals/ObjectMgr.cpp | |
parent | 7870ca8fdc030d102e91ac15756e3d22332676b0 (diff) |
Core/Misc: Properly sanitize ReputationSpillover data
Fix an issue added in 024b57bb74a664cd515cf0822d4b8e939a91fe03 that didn't properly skip ReputationSpillover rows with invalid data.
Fix also a static analysis issue reported by Coverity.
(cherry picked from commit 95b1204798d3ab2a141f81b294b064255c335b8a)
Conflicts:
src/server/game/Globals/ObjectMgr.cpp
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index d07ec212d0c..f0d7d039dd5 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -7078,6 +7078,7 @@ void ObjectMgr::LoadReputationSpilloverTemplate() continue; } + bool invalidSpilloverFaction = false; for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i) { if (repTemplate.faction[i]) @@ -7087,47 +7088,28 @@ void ObjectMgr::LoadReputationSpilloverTemplate() if (!factionSpillover) { TC_LOG_ERROR("sql.sql", "Spillover faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template` for faction %u, skipping", repTemplate.faction[i], factionId); - continue; + invalidSpilloverFaction = true; + break; } if (factionSpillover->reputationListID < 0) { TC_LOG_ERROR("sql.sql", "Spillover faction (faction.dbc) %u for faction %u in `reputation_spillover_template` can not be listed for client, and then useless, skipping", repTemplate.faction[i], factionId); - continue; + invalidSpilloverFaction = true; + break; } if (repTemplate.faction_rank[i] >= MAX_REPUTATION_RANK) { TC_LOG_ERROR("sql.sql", "Rank %u used in `reputation_spillover_template` for spillover faction %u is not valid, skipping", repTemplate.faction_rank[i], repTemplate.faction[i]); - continue; + invalidSpilloverFaction = true; + break; } } } - FactionEntry const* factionEntry0 = sFactionStore.LookupEntry(repTemplate.faction[0]); - if (repTemplate.faction[0] && !factionEntry0) - { - TC_LOG_ERROR("sql.sql", "Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[0]); + if (invalidSpilloverFaction) continue; - } - FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repTemplate.faction[1]); - if (repTemplate.faction[1] && !factionEntry1) - { - TC_LOG_ERROR("sql.sql", "Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[1]); - continue; - } - FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repTemplate.faction[2]); - if (repTemplate.faction[2] && !factionEntry2) - { - TC_LOG_ERROR("sql.sql", "Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[2]); - continue; - } - FactionEntry const* factionEntry3 = sFactionStore.LookupEntry(repTemplate.faction[3]); - if (repTemplate.faction[3] && !factionEntry3) - { - TC_LOG_ERROR("sql.sql", "Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[3]); - continue; - } _repSpilloverTemplateStore[factionId] = repTemplate; |