mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-20 18:10:02 +01:00
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.
This commit is contained in:
parent
9ca326c8cb
commit
43b0852438
@ -382,7 +382,7 @@ std::string const ChatHelper::FormatSpell(SpellInfo const* spellInfo)
|
|||||||
std::string const ChatHelper::FormatItem(ItemTemplate const* proto, uint32 count, uint32 total)
|
std::string const ChatHelper::FormatItem(ItemTemplate const* proto, uint32 count, uint32 total)
|
||||||
{
|
{
|
||||||
char color[32];
|
char color[32];
|
||||||
sprintf(color, "%x", ItemQualityColors[proto->Quality]);
|
snprintf(color, sizeof(color), "%x", ItemQualityColors[proto->Quality]);
|
||||||
|
|
||||||
std::string itemName;
|
std::string itemName;
|
||||||
const ItemLocale* locale = sObjectMgr->GetItemLocale(proto->ItemId);
|
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)
|
std::string const ChatHelper::FormatQItem(uint32 itemId)
|
||||||
{
|
{
|
||||||
char color[32];
|
char color[32];
|
||||||
sprintf(color, "%x", ItemQualityColors[0]);
|
snprintf(color, sizeof(color), "%x", ItemQualityColors[0]);
|
||||||
|
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << "|c" << color << "|Hitem:" << itemId << ":0:0:0:0:0:0:0"
|
out << "|c" << color << "|Hitem:" << itemId << ":0:0:0:0:0:0:0"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user