From: Pierre Ossman Date: Thu, 19 Jul 2012 11:06:27 +0000 (+0000) Subject: Also check for negative encodings, in case the server is throwing unexpected X-Git-Tag: v1.2.90~143 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=229229648fa3c2e035306d1845a20c9240b1a383;p=tigervnc.git 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 --- 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; }