From 0870dd15a88c370da8bf68d2bb20ff49ba6aa88b Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 10 Dec 2021 02:04:19 -0600 Subject: [PATCH] Fix improper null termination when stripping clipboard text --- app/streaming/input/keyboard.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/streaming/input/keyboard.cpp b/app/streaming/input/keyboard.cpp index 0b756a7b..5343ef33 100644 --- a/app/streaming/input/keyboard.cpp +++ b/app/streaming/input/keyboard.cpp @@ -107,7 +107,9 @@ void SdlInputHandler::performSpecialKeyCombo(KeyCombo combo) // each newline in the source, so we fix up any CRLFs into just a single LF. for (char* c = text; *c != 0; c++) { if (*c == '\r' && *(c + 1) == '\n') { - memmove(c, c + 1, strlen(c) - 1); + // We're using strlen() rather than strlen() - 1 since we need to add 1 + // to copy the null terminator which is not included in strlen()'s count. + memmove(c, c + 1, strlen(c)); } }