From b56c36fed5da00f0dfb5b51c87af2dada0f93557 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Tue, 27 Oct 2026 23:33:08 -0400 Subject: [PATCH] plugins/channelrx/remotetcpsink: Fix message buffer overrun Fix Coverity CID 652660 by allocating an extra byte for the message buffer and null-terminating it after a successful read. This ensures QString::fromUtf8() does not read beyond the received message. Signed-off-by: Robin Getz --- plugins/channelrx/remotetcpsink/remotetcpsinksink.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/channelrx/remotetcpsink/remotetcpsinksink.cpp b/plugins/channelrx/remotetcpsink/remotetcpsinksink.cpp index 46e629095..f57d00700 100644 --- a/plugins/channelrx/remotetcpsink/remotetcpsinksink.cpp +++ b/plugins/channelrx/remotetcpsink/remotetcpsinksink.cpp @@ -1213,10 +1213,11 @@ void RemoteTCPSinkSink::processCommand() quint32 msgLen = RemoteTCPProtocol::extractUInt32(&cmd[1]); try { - char *buf = new char[msgLen]; + char *buf = new char[msgLen + 1]; len = client->read((char *)buf, msgLen); if (len == (int) msgLen && msgLen) { + buf[msgLen] = '\0'; bool broadcast = (bool) buf[0]; int i; for (i = 1; i < (int) msgLen; i++)