From 229229648fa3c2e035306d1845a20c9240b1a383 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 19 Jul 2012 11:06:27 +0000 Subject: [PATCH] Also check for negative encodings, in case the server is throwing unexpected garbage at us. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4942 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- common/rfb/CMsgReader.cxx | 2 +- common/rfb/Decoder.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/rfb/CMsgReader.cxx b/common/rfb/CMsgReader.cxx index e3b73bf5..63d31d1a 100644 --- a/common/rfb/CMsgReader.cxx +++ b/common/rfb/CMsgReader.cxx @@ -100,7 +100,7 @@ void CMsgReader::readRect(const Rect& r, int encoding) readCopyRect(r); } else { - if (encoding > encodingMax) { + if (!Decoder::supported(encoding)) { fprintf(stderr, "Unknown rect encoding %d\n", encoding); throw Exception("Unknown rect encoding"); } diff --git a/common/rfb/Decoder.cxx b/common/rfb/Decoder.cxx index 61d8bcee..193b61c0 100644 --- a/common/rfb/Decoder.cxx +++ b/common/rfb/Decoder.cxx @@ -34,12 +34,12 @@ DecoderCreateFnType Decoder::createFns[encodingMax+1] = { 0 }; bool Decoder::supported(int encoding) { - return encoding <= encodingMax && createFns[encoding]; + return encoding >= 0 && encoding <= encodingMax && createFns[encoding]; } Decoder* Decoder::createDecoder(int encoding, CMsgReader* reader) { - if (encoding <= encodingMax && createFns[encoding]) + if (supported(encoding)) return (*createFns[encoding])(reader); return 0; } -- 2.39.5