Received: from eggs.gnu.org ([2001:4830:134:3::10]:55406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPPS8-0001eF-Bi for qemu-devel@nongnu.org; Tue, 19 Jul 2016 03:28:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPPS4-0005GB-4o for qemu-devel@nongnu.org; Tue, 19 Jul 2016 03:28:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33875) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPPS3-0005Et-Vi for qemu-devel@nongnu.org; Tue, 19 Jul 2016 03:28:24 -0400 From: Gerd Hoffmann Date: Tue, 19 Jul 2016 09:28:17 +0200 Message-Id: <1468913298-23781-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1468913298-23781-1-git-send-email-kraxel@redhat.com> References: <1468913298-23781-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 2/3] vnc-enc-tight: fix off-by-one bug List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Herongguang (Stephen)" , Gerd Hoffmann From: "Herongguang (Stephen)" In tight_encode_indexed_rect32, buf(or src)=E2=80=99s size is count. In f= or loop, the logic is supposed to be that i is an index into src, i should be incremented when incrementing src. This is broken when src is incremented but i is not before while loop, resulting in off-by-one bug in while loop. Signed-off-by: He Rongguang Message-id: 5784B8EB.7010008@huawei.com Signed-off-by: Gerd Hoffmann --- ui/vnc-enc-tight.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c index b8581dd..877c093 100644 --- a/ui/vnc-enc-tight.c +++ b/ui/vnc-enc-tight.c @@ -461,9 +461,10 @@ static int tight_fill_palette(VncState *vs, int x, i= nt y, = \ src =3D (uint##bpp##_t *) buf; = \ = \ - for (i =3D 0; i < count; i++) { = \ + for (i =3D 0; i < count; ) { = \ = \ rgb =3D *src++; = \ + i++; = \ rep =3D 0; = \ while (i < count && *src =3D=3D rgb) { = \ rep++, src++, i++; = \ --=20 1.8.3.1