From f8a359dfe94cb85dd7d68b8317d7288d6f92192c Mon Sep 17 00:00:00 2001 From: dongresource Date: Sat, 19 Dec 2020 05:46:38 +0100 Subject: [PATCH] Do not truncate emails to 127 characters And assert that we never supply a string long enough for sanitizeText() to truncate. --- src/ChatManager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ChatManager.cpp b/src/ChatManager.cpp index 9da9397..ceb50e1 100644 --- a/src/ChatManager.cpp +++ b/src/ChatManager.cpp @@ -873,11 +873,14 @@ void ChatManager::announcementHandler(CNSocket* sock, CNPacketData* data) { // we only allow plain ascii, at least for now std::string ChatManager::sanitizeText(std::string text, bool allowNewlines) { int i; - char buf[128]; + const int BUFSIZE = 512; + char buf[BUFSIZE]; + + assert(text.size() < BUFSIZE); i = 0; for (char c : text) { - if (i >= 127) + if (i >= BUFSIZE-1) break; if (!allowNewlines && c == '\n')