From: Adam Tkac Date: Wed, 21 Jul 2010 14:12:18 +0000 (+0000) Subject: [Bugfix] Extend encoding range checks to handle negative encodings well. X-Git-Tag: v1.0.90~200 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ea633a79bdaf4e1a00df26f5d4cdcf60e39247c1;p=tigervnc.git [Bugfix] Extend encoding range checks to handle negative encodings well. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4113 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/common/rfb/ConnParams.cxx b/common/rfb/ConnParams.cxx index 9bfc3027..3ee37087 100644 --- a/common/rfb/ConnParams.cxx +++ b/common/rfb/ConnParams.cxx @@ -129,7 +129,7 @@ void ConnParams::setEncodings(int nEncodings, const rdr::S32* encodings) encodings[i] <= pseudoEncodingQualityLevel9) { noJpeg = false; qualityLevel = encodings[i] - pseudoEncodingQualityLevel0; - } else if (encodings[i] <= encodingMax && Encoder::supported(encodings[i])) + } else if (Encoder::supported(encodings[i])) currentEncoding_ = encodings[i]; } } diff --git a/common/rfb/Encoder.cxx b/common/rfb/Encoder.cxx index b0bd147e..5de75430 100644 --- a/common/rfb/Encoder.cxx +++ b/common/rfb/Encoder.cxx @@ -34,12 +34,12 @@ EncoderCreateFnType Encoder::createFns[encodingMax+1] = { 0 }; bool Encoder::supported(int encoding) { - return encoding <= encodingMax && createFns[encoding]; + return encoding >= 0 && encoding <= encodingMax && createFns[encoding]; } Encoder* Encoder::createEncoder(int encoding, SMsgWriter* writer) { - if (encoding <= encodingMax && createFns[encoding]) + if (supported(encoding)) return (*createFns[encoding])(writer); return 0; }