aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2020-03-15 16:07:40 +0100
committerShauren <shauren.trinity@gmail.com>2021-12-23 19:45:40 +0100
commit7d8926c55d81997380fce6a5046a8d6e6de0ec9c (patch)
tree13726f215278dd6deaad8040832f2a748dc9bd25 /src
parentd6bd4fbd7a3a5c53ba6f2793bed53f214bd56b27 (diff)
Core/Channels: Limit channel length to 31 characters
(cherry picked from commit 2707877cf6ab34727c348190ca15499ef0205b1c)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Handlers/ChannelHandler.cpp28
1 files changed, 25 insertions, 3 deletions
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 <cctype>
-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;