]> source.dussan.org Git - tigervnc.git/commitdiff
Also check for negative encodings, in case the server is throwing unexpected
authorPierre Ossman <ossman@cendio.se>
Thu, 19 Jul 2012 11:06:27 +0000 (11:06 +0000)
committerPierre Ossman <ossman@cendio.se>
Thu, 19 Jul 2012 11:06:27 +0000 (11:06 +0000)
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
common/rfb/Decoder.cxx

index e3b73bf57b84ba12a25b36831aa3672ff67786fa..63d31d1a7d076d8551a8bbf0483ee18bd0799026 100644 (file)
@@ -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");
     }
index 61d8bceee96c6fd8d91776dc2834a8d189c86cac..193b61c0149d0da1c5e0bbef0612b857bf8edfe5 100644 (file)
@@ -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;
 }