summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Luchterhand <52720531+maxluchterhand1@users.noreply.github.com>2020-03-24 09:39:54 +0100
committerGitHub <noreply@github.com>2020-03-24 09:39:54 +0100
commit08a9991b5aef9ff36bd39296cbdec1cc83209d7b (patch)
tree4c294fd4c0a78ffc5c20e813fa8b896566c065f6
parentFix certain item drops (#4536) (diff)
downloadcuberite-08a9991b5aef9ff36bd39296cbdec1cc83209d7b.tar
cuberite-08a9991b5aef9ff36bd39296cbdec1cc83209d7b.tar.gz
cuberite-08a9991b5aef9ff36bd39296cbdec1cc83209d7b.tar.bz2
cuberite-08a9991b5aef9ff36bd39296cbdec1cc83209d7b.tar.lz
cuberite-08a9991b5aef9ff36bd39296cbdec1cc83209d7b.tar.xz
cuberite-08a9991b5aef9ff36bd39296cbdec1cc83209d7b.tar.zst
cuberite-08a9991b5aef9ff36bd39296cbdec1cc83209d7b.zip
-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: