From e75c31d524f76acf07240630f0fc92a8df0b0e9d Mon Sep 17 00:00:00 2001 From: Mitch Freeman <65987027+neckkola@users.noreply.github.com> Date: Tue, 28 Nov 2023 20:03:32 -0400 Subject: [PATCH] [Bug Fix] Guild Message Limits (#3724) Mail to 'Guild' was failing after after 50ish members. The buffer was set at 512, which cut truncated the message and caused the issue. Refactored to adjust the size of the buffer based on the inbound message size. --- zone/worldserver.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index 290cf1a17..01e03450b 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -3393,17 +3393,20 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } bool WorldServer::SendChannelMessage(Client* from, const char* to, uint8 chan_num, uint32 guilddbid, uint8 language, uint8 lang_skill, const char* message, ...) { - if (!worldserver.Connected()) + if (!worldserver.Connected()) { return false; + } + va_list argptr; - char buffer[512]; + auto length = strlen(message) + 1; + char* buffer = new char[length]; va_start(argptr, message); - vsnprintf(buffer, 512, message, argptr); + vsnprintf(buffer, length, message, argptr); va_end(argptr); - buffer[511] = '\0'; + buffer[length - 1] = '\0'; - auto pack = new ServerPacket(ServerOP_ChannelMessage, sizeof(ServerChannelMessage_Struct) + strlen(buffer) + 1); + auto pack = new ServerPacket(ServerOP_ChannelMessage, sizeof(ServerChannelMessage_Struct) + length); ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*)pack->pBuffer; if (from == 0) { @@ -3432,6 +3435,7 @@ bool WorldServer::SendChannelMessage(Client* from, const char* to, uint8 chan_nu bool ret = SendPacket(pack); safe_delete(pack); + safe_delete_array(buffer); return ret; }