Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JxYmp-0005nx-Od for qemu-devel@nongnu.org; Sat, 17 May 2008 22:38:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JxYmo-0005mG-6l for qemu-devel@nongnu.org; Sat, 17 May 2008 22:38:11 -0400 Received: from [199.232.76.173] (port=46515 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JxYmn-0005lr-RR for qemu-devel@nongnu.org; Sat, 17 May 2008 22:38:09 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]:40720) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JxYmn-0005iN-FV for qemu-devel@nongnu.org; Sat, 17 May 2008 22:38:09 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e36.co.us.ibm.com (8.13.8/8.13.8) with ESMTP id m4I2Ym4E002465 for ; Sat, 17 May 2008 22:34:48 -0400 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m4I2Ygwl017684 for ; Sat, 17 May 2008 20:34:47 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m4I2Yg96024266 for ; Sat, 17 May 2008 20:34:42 -0600 From: Anthony Liguori Date: Sat, 17 May 2008 21:34:12 -0500 Message-Id: <1211078052-4595-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH] Prevent SEGV in VNC server for old clients Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Marcelo Tosatti If the client does not support the DesktopResize pseudo-encoding, then vs->{width,height} may be smaller than ds->{width,height}. dirty_row is sized according to vs->{width,height}, not ds->{width,height}. This patch makes sure to bound the update region to vs->{width,height} to avoid a possible SEGV. Signed-off-by: Anthony Liguori Reported-by: Marcelo Tosatti diff --git a/vnc.c b/vnc.c index 842124b..4b57838 100644 --- a/vnc.c +++ b/vnc.c @@ -265,6 +265,11 @@ static void vnc_dpy_update(DisplayState *ds, int x, int y, int w, int h) w += (x % 16); x -= (x % 16); + x = MIN(x, vs->width); + y = MIN(y, vs->height); + w = MIN(x + w, vs->width) - x; + h = MIN(y + h, vs->height) - y; + for (; y < h; y++) for (i = 0; i < w; i += 16) vnc_set_bit(vs->dirty_row[y], (x + i) / 16);