Browse Source

Fix crash from integer overflow in SMsgReader::readClientCutText

The length sent by client is U32, but is converted into int. If it was bigger than 0x7fffffff the resulting int is negative, it passes the check against maxCutText and later throws std::bad_alloc from CharArray which takes down the whole server.

All the Streaming API deals with lengths in ints, so we can't tell it to skip that big amount of data. And it is not realistic to expect more than 2GB of clipboard data anyway. So lets just throw rdr::Exception that will disconnect this client and keep the server alive.
tags/v1.7.90
Michal Srb 7 years ago
parent
commit
bf3bdac082
1 changed files with 3 additions and 0 deletions
  1. 3
    0
      common/rfb/SMsgReader.cxx

+ 3
- 0
common/rfb/SMsgReader.cxx View File

@@ -200,6 +200,9 @@ void SMsgReader::readClientCutText()
{
is->skip(3);
int len = is->readU32();
if (len < 0) {
throw Exception("Cut text too long.");
}
if (len > maxCutText) {
is->skip(len);
vlog.error("Cut text too long (%d bytes) - ignoring", len);

Loading…
Cancel
Save