vnc: Fix tight_detect_smooth_image() for lossless case
authorMarkus Armbruster <armbru@redhat.com>
Fri, 21 Feb 2014 15:42:52 +0000 (16:42 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 16 Jul 2014 00:28:02 +0000 (19:28 -0500)
VncTight member uint8_t quality is either (uint8_t)-1 for lossless or
less than 10 for lossy.

tight_detect_smooth_image() first promotes it to int, then compares
with -1.  Always unequal, so we always execute the lossy code.  Reads
beyond tight_conf[] and returns crap when quality is actually
lossless.

Compare to (uint8_t)-1 instead, like we do elsewhere.

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 2e7bcdb99adbd8fc10ad9ddcf93bd2bf3c0f1f2d)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
ui/vnc-enc-tight.c

index e6966aebc355a826ae08c51d5174fec97d02106c..59b59c0c79c63e8783dae0740a49f8ac2c2d9524 100644 (file)
@@ -330,7 +330,7 @@ tight_detect_smooth_image(VncState *vs, int w, int h)
     } else {
         errors = tight_detect_smooth_image16(vs, w, h);
     }
-    if (quality != -1) {
+    if (quality != (uint8_t)-1) {
         return (errors < tight_conf[quality].jpeg_threshold);
     }
     return (errors < tight_conf[compression].gradient_threshold);