From 01ab2a315c63c51f85fe5389b19e6c6dfb89e0b8 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 29 Mar 2026 21:35:56 -0700 Subject: [PATCH] fix: achievement message silently truncated by char[256] snprintf Long achievement names combined with sender name could exceed 256 bytes, silently cutting the message mid-word in chat. Replaced with std::string concatenation which grows dynamically. --- src/game/spell_handler.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/game/spell_handler.cpp b/src/game/spell_handler.cpp index 326840b0..d02b24be 100644 --- a/src/game/spell_handler.cpp +++ b/src/game/spell_handler.cpp @@ -1413,15 +1413,12 @@ void SpellHandler::handleAchievementEarned(network::Packet& packet) { static_cast(guid)); senderName = tmp; } - char buf[256]; - if (!achName.empty()) { - std::snprintf(buf, sizeof(buf), "%s has earned the achievement: %s", - senderName.c_str(), achName.c_str()); - } else { - std::snprintf(buf, sizeof(buf), "%s has earned an achievement! (ID %u)", - senderName.c_str(), achievementId); - } - owner_.addSystemChatMessage(buf); + // Use std::string instead of fixed char[256] — achievement names can be + // long and combined with senderName could exceed 256 bytes, silently truncating. + std::string msg = senderName + (!achName.empty() + ? " has earned the achievement: " + achName + : " has earned an achievement! (ID " + std::to_string(achievementId) + ")"); + owner_.addSystemChatMessage(msg); } LOG_INFO("SMSG_ACHIEVEMENT_EARNED: guid=0x", std::hex, guid, std::dec,