summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ClientHandle.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 5fbea5403..f0c033107 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -43,6 +43,9 @@
/** Maximum number of block change interactions a player can perform per tick - exceeding this causes a kick */
#define MAX_BLOCK_CHANGE_INTERACTIONS 20
+/** Maximum number of bytes that a chat message sent by a player may consist of */
+#define MAX_CHAT_MSG_LENGTH 1024
+
/** The interval for sending pings to clients.
Vanilla sends one ping every 1 second. */
static const std::chrono::milliseconds PING_TIME_MS = std::chrono::milliseconds(1000);
@@ -1549,6 +1552,13 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
void cClientHandle::HandleChat(const AString & a_Message)
{
+ if ((a_Message.size()) > MAX_CHAT_MSG_LENGTH)
+ {
+ this->Kick(std::string("Please don't exceed the maximum message length of ")
+ + std::to_string(MAX_CHAT_MSG_LENGTH)
+ );
+ return;
+ }
// We no longer need to postpone message processing, because the messages already arrive in the Tick thread
// If a command, perform it: