From 7d8926c55d81997380fce6a5046a8d6e6de0ec9c Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sun, 15 Mar 2020 16:07:40 +0100 Subject: Core/Channels: Limit channel length to 31 characters (cherry picked from commit 2707877cf6ab34727c348190ca15499ef0205b1c) --- src/server/game/Handlers/ChannelHandler.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/server/game/Handlers/ChannelHandler.cpp b/src/server/game/Handlers/ChannelHandler.cpp index 3d55008db27..435b62b9719 100644 --- a/src/server/game/Handlers/ChannelHandler.cpp +++ b/src/server/game/Handlers/ChannelHandler.cpp @@ -25,8 +25,8 @@ #include "Player.h" #include -static size_t const MAX_CHANNEL_NAME_STR = 0x31; -static size_t const MAX_CHANNEL_PASS_STR = 31; +static size_t const MAX_CHANNEL_NAME_STR = 31; +static size_t const MAX_CHANNEL_PASS_STR = 127; void WorldSession::HandleJoinChannel(WorldPackets::Channel::JoinChannel& packet) { @@ -44,8 +44,30 @@ void WorldSession::HandleJoinChannel(WorldPackets::Channel::JoinChannel& packet) return; } - if (packet.ChannelName.empty()) + if (packet.ChannelName.empty() || isdigit((unsigned char)packet.ChannelName[0])) + { + WorldPackets::Channel::ChannelNotify channelNotify; + channelNotify.Type = CHAT_INVALID_NAME_NOTICE; + channelNotify._Channel = packet.ChannelName; + SendPacket(channelNotify.Write()); + return; + } + + if (packet.ChannelName.length() > MAX_CHANNEL_NAME_STR) + { + WorldPackets::Channel::ChannelNotify channelNotify; + channelNotify.Type = CHAT_INVALID_NAME_NOTICE; + channelNotify._Channel = packet.ChannelName; + SendPacket(channelNotify.Write()); + TC_LOG_ERROR("network", "Player %s tried to create a channel with a name more than " SZFMTD " characters long - blocked", GetPlayer()->GetGUID().ToString().c_str(), MAX_CHANNEL_NAME_STR); return; + } + + if (packet.Password.length() > MAX_CHANNEL_PASS_STR) + { + TC_LOG_ERROR("network", "Player %s tried to create a channel with a password more that " SZFMTD " characters long - blocked", GetPlayer()->GetGUID().ToString().c_str(), MAX_CHANNEL_PASS_STR); + return; + } if (!ValidateHyperlinksAndMaybeKick(packet.ChannelName)) return; -- cgit v1.2.3