From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:45096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RoAbB-0008Nk-63 for qemu-devel@nongnu.org; Fri, 20 Jan 2012 04:17:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RoAb1-0002uL-Kh for qemu-devel@nongnu.org; Fri, 20 Jan 2012 04:17:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12192) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RoAb1-0002tz-4G for qemu-devel@nongnu.org; Fri, 20 Jan 2012 04:17:19 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0K9HIHu029593 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 20 Jan 2012 04:17:18 -0500 From: Gerd Hoffmann Date: Fri, 20 Jan 2012 10:17:11 +0100 Message-Id: <1327051033-2812-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1327051033-2812-1-git-send-email-kraxel@redhat.com> References: <1327051033-2812-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 1/3] Fix vnc memory corruption with width = 1400 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann vnc assumes that the screen width is a multiple of 16 in several places. If this is not the case vnc will overrun buffers, corrupt memory, make qemu crash. This is the minimum fix for this bug. It makes sure we don't overrun the scanline, thereby fixing the segfault. The rendering is *not* correct though, there is a black border at the right side of the screen, 8 pixels wide because 1400 % 16 == 8. Signed-off-by: Gerd Hoffmann --- ui/vnc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index 16b79ec..5752bf8 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2445,7 +2445,7 @@ static int vnc_refresh_server_surface(VncDisplay *vd) guest_ptr = guest_row; server_ptr = server_row; - for (x = 0; x < vd->guest.ds->width; + for (x = 0; x + 15 < vd->guest.ds->width; x += 16, guest_ptr += cmp_bytes, server_ptr += cmp_bytes) { if (!test_and_clear_bit((x / 16), vd->guest.dirty[y])) continue; -- 1.7.1