Browse Source

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 <rgetz503@gmail.com>
chirpmodem-v8.1.0
Robin Getz 4 weeks ago
parent
commit
b56c36fed5
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 3
      plugins/channelrx/remotetcpsink/remotetcpsinksink.cpp

3
plugins/channelrx/remotetcpsink/remotetcpsinksink.cpp

@ -1213,10 +1213,11 @@ void RemoteTCPSinkSink::processCommand() @@ -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++)

Loading…
Cancel
Save