summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorM'Dic <joshua.lee.betts@gmail.com>2023-01-23 06:13:27 -0500
committerGitHub <noreply@github.com>2023-01-23 06:13:27 -0500
commit437d93926f64819c764a935cfb59540ef903ac25 (patch)
treeb8c73af2642ae846586ef2013879d0c096d9c653
parent513dab074022a25cf3451a9daee3ba2f4b184866 (diff)
fix (core): macos12 depreciation workflow error / security CWE-120 (#14746)
* fix (core): macos12 depreciation workflow error Fix workflow error message: azerothcore-wotlk/src/common/Utilities/Util.cpp:558:9: fatal error: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations] sprintf(buffer, "%02X", bytes[i]); * Update BattlegroundAV.cpp * more macos12 fixit * Update spell_generic.cpp
-rw-r--r--src/common/Utilities/Util.cpp2
-rw-r--r--src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp10
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp4
-rw-r--r--src/server/game/Spells/SpellEffects.cpp2
-rw-r--r--src/server/game/Spells/SpellScript.cpp4
-rw-r--r--src/server/scripts/Events/brewfest.cpp4
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp2
-rw-r--r--src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp2
-rw-r--r--src/server/scripts/Northrend/VaultOfArchavon/boss_archavon.cpp2
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp2
10 files changed, 17 insertions, 17 deletions
diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp
index 8095aaa083..0020b0102e 100644
--- a/src/common/Utilities/Util.cpp
+++ b/src/common/Utilities/Util.cpp
@@ -555,7 +555,7 @@ std::string Acore::Impl::ByteArrayToHexStr(uint8 const* bytes, size_t arrayLen,
for (int32 i = init; i != end; i += op)
{
char buffer[4];
- sprintf(buffer, "%02X", bytes[i]);
+ snprintf(buffer, sizeof(buffer), "%02X", bytes[i]);
ss << buffer;
}
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
index 6518e7066e..7c5f1db931 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
@@ -650,9 +650,9 @@ void BattlegroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node)
//send a nice message to all :)
char buf[256];
if (IsTower(node))
- sprintf(buf, GetAcoreString(LANG_BG_AV_TOWER_TAKEN), GetNodeName(node), (ownerId == TEAM_ALLIANCE) ? GetAcoreString(LANG_BG_AV_ALLY) : GetAcoreString(LANG_BG_AV_HORDE));
+ snprintf(buf, sizeof(buf), GetAcoreString(LANG_BG_AV_TOWER_TAKEN), GetNodeName(node), (ownerId == TEAM_ALLIANCE) ? GetAcoreString(LANG_BG_AV_ALLY) : GetAcoreString(LANG_BG_AV_HORDE));
else
- sprintf(buf, GetAcoreString(LANG_BG_AV_GRAVE_TAKEN), GetNodeName(node), (ownerId == TEAM_ALLIANCE) ? GetAcoreString(LANG_BG_AV_ALLY) : GetAcoreString(LANG_BG_AV_HORDE));
+ snprintf(buf, sizeof(buf), GetAcoreString(LANG_BG_AV_GRAVE_TAKEN), GetNodeName(node), (ownerId == TEAM_ALLIANCE) ? GetAcoreString(LANG_BG_AV_ALLY) : GetAcoreString(LANG_BG_AV_HORDE));
Creature* creature = GetBGCreature(AV_CPLACE_HERALD);
if (creature)
@@ -729,7 +729,7 @@ void BattlegroundAV::ChangeMineOwner(uint8 mine, TeamId teamId, bool initial)
{
m_Mine_Reclaim_Timer[mine] = AV_MINE_RECLAIM_TIMER;
char buf[256];
- sprintf(buf, GetAcoreString(LANG_BG_AV_MINE_TAKEN), (teamId == TEAM_ALLIANCE) ? GetAcoreString(LANG_BG_AV_ALLY) : GetAcoreString(LANG_BG_AV_HORDE),
+ snprintf(buf, sizeof(buf), GetAcoreString(LANG_BG_AV_MINE_TAKEN), (teamId == TEAM_ALLIANCE) ? GetAcoreString(LANG_BG_AV_ALLY) : GetAcoreString(LANG_BG_AV_HORDE),
GetAcoreString((mine == AV_NORTH_MINE) ? LANG_BG_AV_MINE_NORTH : LANG_BG_AV_MINE_SOUTH));
Creature* creature = GetBGCreature(AV_CPLACE_HERALD);
if (creature)
@@ -983,7 +983,7 @@ void BattlegroundAV::EventPlayerDefendsPoint(Player* player, uint32 object)
}
//send a nice message to all :)
char buf[256];
- sprintf(buf, GetAcoreString((IsTower(node)) ? LANG_BG_AV_TOWER_DEFENDED : LANG_BG_AV_GRAVE_DEFENDED), GetNodeName(node), (teamId == TEAM_ALLIANCE) ? GetAcoreString(LANG_BG_AV_ALLY) : GetAcoreString(LANG_BG_AV_HORDE));
+ snprintf(buf, sizeof(buf), GetAcoreString((IsTower(node)) ? LANG_BG_AV_TOWER_DEFENDED : LANG_BG_AV_GRAVE_DEFENDED), GetNodeName(node), (teamId == TEAM_ALLIANCE) ? GetAcoreString(LANG_BG_AV_ALLY) : GetAcoreString(LANG_BG_AV_HORDE));
Creature* creature = GetBGCreature(AV_CPLACE_HERALD);
if (creature)
YellToAll(creature, buf, LANG_UNIVERSAL);
@@ -1095,7 +1095,7 @@ void BattlegroundAV::EventPlayerAssaultsPoint(Player* player, uint32 object)
//send a nice message to all :)
char buf[256];
- sprintf(buf, (IsTower(node)) ? GetAcoreString(LANG_BG_AV_TOWER_ASSAULTED) : GetAcoreString(LANG_BG_AV_GRAVE_ASSAULTED), GetNodeName(node), (teamId == TEAM_ALLIANCE) ? GetAcoreString(LANG_BG_AV_ALLY) : GetAcoreString(LANG_BG_AV_HORDE));
+ snprintf(buf, sizeof(buf), (IsTower(node)) ? GetAcoreString(LANG_BG_AV_TOWER_ASSAULTED) : GetAcoreString(LANG_BG_AV_GRAVE_ASSAULTED), GetNodeName(node), (teamId == TEAM_ALLIANCE) ? GetAcoreString(LANG_BG_AV_ALLY) : GetAcoreString(LANG_BG_AV_HORDE));
Creature* creature = GetBGCreature(AV_CPLACE_HERALD);
if (creature)
YellToAll(creature, buf, LANG_UNIVERSAL);
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 8a2e873318..f95ed05ad4 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -188,7 +188,7 @@ std::string GetScriptCommandName(ScriptCommands command)
default:
{
char sz[32];
- sprintf(sz, "Unknown command: %d", command);
+ snprintf(sz, sizeof(sz), "Unknown command: %d", command);
res = sz;
break;
}
@@ -199,7 +199,7 @@ std::string GetScriptCommandName(ScriptCommands command)
std::string ScriptInfo::GetDebugInfo() const
{
char sz[256];
- sprintf(sz, "%s ('%s' script id: %u)", GetScriptCommandName(command).c_str(), GetScriptsTableNameByType(type).c_str(), id);
+ snprintf(sz, sizeof(sz), "%s ('%s' script id: %u)", GetScriptCommandName(command).c_str(), GetScriptsTableNameByType(type).c_str(), id);
return std::string(sz);
}
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 3a92f0472c..298f26e787 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -3900,7 +3900,7 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
const char* gender = "his";
if (m_caster->getGender() > 0)
gender = "her";
- sprintf(buf, "%s rubs %s [Decahedral Dwarven Dice] between %s hands and rolls. One %u and one %u.", m_caster->GetName().c_str(), gender, gender, urand(1, 10), urand(1, 10));
+ snprintf(buf, sizeof(buf), "%s rubs %s [Decahedral Dwarven Dice] between %s hands and rolls. One %u and one %u.", m_caster->GetName().c_str(), gender, gender, urand(1, 10), urand(1, 10));
m_caster->TextEmote(buf);
break;
}
diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp
index 4842cede7d..40e1e219ff 100644
--- a/src/server/game/Spells/SpellScript.cpp
+++ b/src/server/game/Spells/SpellScript.cpp
@@ -136,7 +136,7 @@ std::string _SpellScript::EffectNameCheck::ToString()
return "SPELL_EFFECT_ANY";
default:
char num[10];
- sprintf (num, "%u", effName);
+ snprintf(num, sizeof(num), "%u", effName);
return num;
}
}
@@ -158,7 +158,7 @@ std::string _SpellScript::EffectAuraNameCheck::ToString()
return "SPELL_AURA_ANY";
default:
char num[10];
- sprintf (num, "%u", effAurName);
+ snprintf(num, sizeof(num), "%u", effAurName);
return num;
}
}
diff --git a/src/server/scripts/Events/brewfest.cpp b/src/server/scripts/Events/brewfest.cpp
index b32fdbfeb9..97925f44ed 100644
--- a/src/server/scripts/Events/brewfest.cpp
+++ b/src/server/scripts/Events/brewfest.cpp
@@ -438,7 +438,7 @@ struct npc_dark_iron_attack_generator : public ScriptedAI
if (Creature* herald = me->FindNearestCreature(NPC_DARK_IRON_HERALD, 100.0f))
{
char amount[500];
- sprintf(amount, "We did it boys! Now back to the Grim Guzzler and we'll drink to the %u that were injured!", guzzlerCounter);
+ snprintf(amount, sizeof(amount), "We did it boys! Now back to the Grim Guzzler and we'll drink to the %u that were injured!", guzzlerCounter);
herald->Yell(amount, LANG_UNIVERSAL);
}
@@ -451,7 +451,7 @@ struct npc_dark_iron_attack_generator : public ScriptedAI
if (Creature* herald = me->FindNearestCreature(NPC_DARK_IRON_HERALD, 100.0f))
{
char amount[500];
- sprintf(amount, "RETREAT!! We've already lost %u and we can't afford to lose any more!!", guzzlerCounter);
+ snprintf(amount, sizeof(amount), "RETREAT!! We've already lost %u and we can't afford to lose any more!!", guzzlerCounter);
herald->Yell(amount, LANG_UNIVERSAL);
}
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp
index 89b0266e15..16163a89ba 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_argent_challenge.cpp
@@ -189,7 +189,7 @@ public:
if( Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 55.0f, true) )
{
char buffer[100];
- sprintf(buffer, "Eadric the Pure targets %s with the Hammer of the Righteous!", target->GetName().c_str());
+ snprintf(buffer, sizeof(buffer), "Eadric the Pure targets %s with the Hammer of the Righteous!", target->GetName().c_str());
me->TextEmote(buffer, nullptr, true);
Talk(TEXT_EADRIC_HAMMER);
me->CastSpell(target, SPELL_HAMMER_JUSTICE, true);
diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp
index 8b6b9bed3e..a6088f51e9 100644
--- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp
+++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheChampion/boss_grand_champions.cpp
@@ -654,7 +654,7 @@ public:
case SPELL_TRAMPLE_STUN:
{
char buffer[50];
- sprintf(buffer, "%s is trampled!", me->GetName().c_str());
+ snprintf(buffer, sizeof(buffer), "%s is trampled!", me->GetName().c_str());
me->TextEmote(buffer);
}
break;
diff --git a/src/server/scripts/Northrend/VaultOfArchavon/boss_archavon.cpp b/src/server/scripts/Northrend/VaultOfArchavon/boss_archavon.cpp
index 1f2b507d74..b283a3baaa 100644
--- a/src/server/scripts/Northrend/VaultOfArchavon/boss_archavon.cpp
+++ b/src/server/scripts/Northrend/VaultOfArchavon/boss_archavon.cpp
@@ -152,7 +152,7 @@ class boss_archavon : public CreatureScript
case EVENT_STOMP:
{
char buffer[100];
- sprintf(buffer, "Archavon the Stone Watcher lunges for %s!", me->GetVictim()->GetName().c_str());
+ snprintf(buffer, sizeof(buffer), "Archavon the Stone Watcher lunges for %s!", me->GetVictim()->GetName().c_str());
me->TextEmote(buffer);
DoCastVictim(RAID_MODE(SPELL_STOMP_10, SPELL_STOMP_25));
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index d54ded1fe4..04e116289e 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -137,7 +137,7 @@ class spell_the_flag_of_ownership : public SpellScript
return;
caster->CastSpell(target, 52605, true);
char buff[100];
- sprintf(buff, "%s plants the Flag of Ownership in the corpse of %s.", caster->GetName().c_str(), target->GetName().c_str());
+ snprintf(buff, sizeof(buff), "%s plants the Flag of Ownership in the corpse of %s.", caster->GetName().c_str(), target->GetName().c_str());
caster->TextEmote(buff, caster);
haveTarget = true;
}