aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiztazz <felianther15@gmail.com>2022-04-22 12:59:08 +0200
committerGitHub <noreply@github.com>2022-04-22 12:59:08 +0200
commit0d8672732552b0474e22b077a2318fa87446f25f (patch)
tree1f8198fc56b56f8a9fb4472dc2a383897b825fe0 /src
parentaf5bd270c3b6628b126e0fde8aa2069a552484bd (diff)
Core/Scripts: Fix heap buffer overflow in BRD Tomb of seven event (#27920)
* Core/Scripts: Fix heap buffer overflow in BRD Tomb of seven event * Core/Scripts: Remove magic numbers in brd script, adjust codestyle to tc preference * missing ) Closes #27919
Diffstat (limited to 'src')
-rw-r--r--src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp
index 3ddf17ee310..c4a6c5f9f1e 100644
--- a/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp
+++ b/src/server/scripts/EasternKingdoms/BlackrockMountain/BlackrockDepths/instance_blackrock_depths.cpp
@@ -29,6 +29,7 @@
#define TIMER_TOMBOFTHESEVEN 15000
#define MAX_ENCOUNTER 6
+constexpr uint8 TOMB_OF_SEVEN_BOSS_NUM = 7;
enum Creatures
{
@@ -134,7 +135,7 @@ public:
uint32 BarAleCount;
uint32 GhostKillCount;
- ObjectGuid TombBossGUIDs[7];
+ ObjectGuid TombBossGUIDs[TOMB_OF_SEVEN_BOSS_NUM];
ObjectGuid TombEventStarterGUID;
uint32 TombTimer;
uint32 TombEventCounter;
@@ -193,7 +194,7 @@ public:
case GO_TOMB_ENTER: GoTombEnterGUID = go->GetGUID(); break;
case GO_TOMB_EXIT:
GoTombExitGUID = go->GetGUID();
- if (GhostKillCount >= 7)
+ if (GhostKillCount >= TOMB_OF_SEVEN_BOSS_NUM)
HandleGameObject(ObjectGuid::Empty, true, go);
else
HandleGameObject(ObjectGuid::Empty, false, go);
@@ -257,7 +258,7 @@ public:
break;
}
- if (data == DONE || GhostKillCount >= 7)
+ if (data == DONE || GhostKillCount >= TOMB_OF_SEVEN_BOSS_NUM)
{
OUT_SAVE_INST_DATA;
@@ -363,17 +364,17 @@ public:
for (uint8 i = 0; i < MAX_ENCOUNTER; ++i)
if (encounter[i] == IN_PROGRESS)
encounter[i] = NOT_STARTED;
- if (GhostKillCount > 0 && GhostKillCount < 7)
+ if (GhostKillCount > 0 && GhostKillCount < TOMB_OF_SEVEN_BOSS_NUM)
GhostKillCount = 0;//reset tomb of seven event
- if (GhostKillCount >= 7)
- GhostKillCount = 7;
+ if (GhostKillCount >= TOMB_OF_SEVEN_BOSS_NUM)
+ GhostKillCount = TOMB_OF_SEVEN_BOSS_NUM;
OUT_LOAD_INST_DATA_COMPLETE;
}
void TombOfSevenEvent()
{
- if (GhostKillCount < 7 && TombBossGUIDs[TombEventCounter])
+ if (GhostKillCount < TOMB_OF_SEVEN_BOSS_NUM && TombBossGUIDs[TombEventCounter])
{
if (Creature* boss = instance->GetCreature(TombBossGUIDs[TombEventCounter]))
{
@@ -389,7 +390,7 @@ public:
{
HandleGameObject(GoTombExitGUID, false);//event reseted, close exit door
HandleGameObject(GoTombEnterGUID, true);//event reseted, open entrance door
- for (uint8 i = 0; i < 7; ++i)
+ for (uint8 i = 0; i < TOMB_OF_SEVEN_BOSS_NUM; ++i)
{
if (Creature* boss = instance->GetCreature(TombBossGUIDs[i]))
{
@@ -424,15 +425,19 @@ public:
void Update(uint32 diff) override
{
- if (TombEventStarterGUID && GhostKillCount < 7)
+ if (TombEventStarterGUID && GhostKillCount < TOMB_OF_SEVEN_BOSS_NUM)
{
if (TombTimer <= diff)
{
TombTimer = TIMER_TOMBOFTHESEVEN;
- ++TombEventCounter;
- TombOfSevenEvent();
+ if (TombEventCounter < TOMB_OF_SEVEN_BOSS_NUM)
+ {
+ TombOfSevenEvent();
+ ++TombEventCounter;
+ }
+
// Check Killed bosses
- for (uint8 i = 0; i < 7; ++i)
+ for (uint8 i = 0; i < TOMB_OF_SEVEN_BOSS_NUM; ++i)
{
if (Creature* boss = instance->GetCreature(TombBossGUIDs[i]))
{
@@ -444,7 +449,7 @@ public:
}
} else TombTimer -= diff;
}
- if (GhostKillCount >= 7 && TombEventStarterGUID)
+ if (GhostKillCount >= TOMB_OF_SEVEN_BOSS_NUM && TombEventStarterGUID)
TombOfSevenEnd();
}
};