From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52347) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT60y-0002K0-KS for qemu-devel@nongnu.org; Tue, 09 Feb 2016 05:59:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aT60x-00022J-SS for qemu-devel@nongnu.org; Tue, 09 Feb 2016 05:59:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34655) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aT60x-000227-ND for qemu-devel@nongnu.org; Tue, 09 Feb 2016 05:59:23 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id F11DFC09FABC for ; Tue, 9 Feb 2016 10:59:22 +0000 (UTC) From: Paolo Bonzini Date: Tue, 9 Feb 2016 11:59:17 +0100 Message-Id: <1455015557-15106-3-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] cirrus_vga: fix off-by-one in blit_region_is_unsafe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann The "max" value is being compared with >=, but addr + width points to the first byte that will _not_ be copied. Subtract one like it is already done above for the height. Cc: Gerd Hoffmann Signed-off-by: Paolo Bonzini --- hw/display/cirrus_vga.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index b6ce1c8..e7939d2 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -275,14 +275,14 @@ static bool blit_region_is_unsafe(struct CirrusVGAState *s, int64_t min = addr + ((int64_t)s->cirrus_blt_height-1) * pitch; int32_t max = addr - + s->cirrus_blt_width; + + s->cirrus_blt_width-1; if (min < 0 || max >= s->vga.vram_size) { return true; } } else { int64_t max = addr + ((int64_t)s->cirrus_blt_height-1) * pitch - + s->cirrus_blt_width; + + s->cirrus_blt_width-1; if (max >= s->vga.vram_size) { return true; } -- 2.5.0