aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMichal Srb <michalsrb@gmail.com>2017-03-27 13:37:11 +0300
committerMichal Srb <michalsrb@gmail.com>2017-03-27 13:37:11 +0300
commitbf3bdac082978ca32895a4b6a123016094905689 (patch)
tree7aee1bdc59384cd49acc341b1772ec2afa821d46 /common
parent53f520567202928f908b5f94f6d143e7067a8bdd (diff)
downloadtigervnc-bf3bdac082978ca32895a4b6a123016094905689.tar.gz
tigervnc-bf3bdac082978ca32895a4b6a123016094905689.zip
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.
Diffstat (limited to 'common')
-rw-r--r--common/rfb/SMsgReader.cxx3
1 files changed, 3 insertions, 0 deletions
diff --git a/common/rfb/SMsgReader.cxx b/common/rfb/SMsgReader.cxx
index 89c9a8fd..3c08fd6f 100644
--- a/common/rfb/SMsgReader.cxx
+++ b/common/rfb/SMsgReader.cxx
@@ -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);