From patchwork Fri Feb 21 15:42:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 322928 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 256C72C0327 for ; Sat, 22 Feb 2014 02:43:25 +1100 (EST) Received: from localhost ([::1]:45399 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGsG2-0004CE-0e for incoming@patchwork.ozlabs.org; Fri, 21 Feb 2014 10:43:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGsFi-0004C5-6T for qemu-devel@nongnu.org; Fri, 21 Feb 2014 10:43:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGsFc-0008Kc-6i for qemu-devel@nongnu.org; Fri, 21 Feb 2014 10:43:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3869) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGsFb-0008KT-Ur for qemu-devel@nongnu.org; Fri, 21 Feb 2014 10:42:56 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1LFgt5f001078 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Feb 2014 10:42:55 -0500 Received: from blackfin.pond.sub.org (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1LFgrds030273 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 21 Feb 2014 10:42:54 -0500 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6CF19200CF; Fri, 21 Feb 2014 16:42:52 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 21 Feb 2014 16:42:52 +0100 Message-Id: <1392997372-6224-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kraxel@redhat.com Subject: [Qemu-devel] [PATCH] vnc: Fix tight_detect_smooth_image() for lossless case X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- ui/vnc-enc-tight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c index e6966ae..59b59c0 100644 --- a/ui/vnc-enc-tight.c +++ b/ui/vnc-enc-tight.c @@ -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);