From 43b085243819556d076d217d5fa03aa39ad78704 Mon Sep 17 00:00:00 2001 From: Not Date: Fri, 9 May 2025 10:01:21 -0400 Subject: [PATCH] Update ChatHelper.cpp, Replace sprintf with snprintf (#1278) Use snprintf instead of sprintf for item color formatting to prevent buffer overflows and to silence warnings in macOS versions. --- src/ChatHelper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ChatHelper.cpp b/src/ChatHelper.cpp index 50e506cb..1edf45c2 100644 --- a/src/ChatHelper.cpp +++ b/src/ChatHelper.cpp @@ -382,7 +382,7 @@ std::string const ChatHelper::FormatSpell(SpellInfo const* spellInfo) std::string const ChatHelper::FormatItem(ItemTemplate const* proto, uint32 count, uint32 total) { char color[32]; - sprintf(color, "%x", ItemQualityColors[proto->Quality]); + snprintf(color, sizeof(color), "%x", ItemQualityColors[proto->Quality]); std::string itemName; const ItemLocale* locale = sObjectMgr->GetItemLocale(proto->ItemId); @@ -409,7 +409,7 @@ std::string const ChatHelper::FormatItem(ItemTemplate const* proto, uint32 count std::string const ChatHelper::FormatQItem(uint32 itemId) { char color[32]; - sprintf(color, "%x", ItemQualityColors[0]); + snprintf(color, sizeof(color), "%x", ItemQualityColors[0]); std::ostringstream out; out << "|c" << color << "|Hitem:" << itemId << ":0:0:0:0:0:0:0"