From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=53013 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q1aZh-0002Yp-12 for qemu-devel@nongnu.org; Mon, 21 Mar 2011 04:34:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q1aZf-0007RX-0A for qemu-devel@nongnu.org; Mon, 21 Mar 2011 04:34:52 -0400 Received: from smtp5.tech.numericable.fr ([82.216.111.41]:46754) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q1aZe-0007RM-Ra for qemu-devel@nongnu.org; Mon, 21 Mar 2011 04:34:50 -0400 From: Corentin Chary Date: Mon, 21 Mar 2011 09:34:38 +0100 Message-Id: <1300696478-6051-5-git-send-email-corentin.chary@gmail.com> In-Reply-To: <1300696478-6051-1-git-send-email-corentin.chary@gmail.com> References: <1300696478-6051-1-git-send-email-corentin.chary@gmail.com> Subject: [Qemu-devel] [PATCH 4/4] vnc: Limit r/w access to size of allocated memory List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: Anthony Liguori , qemu-devel , Blue Swirl , Corentin Chary , Paolo Bonzini From: Stefan Weil This fixes memory reads and writes which exceeded the upper limit of allocated memory vd->guest.ds->data and vd->server->data. Cc: Anthony Liguori Signed-off-by: Stefan Weil Signed-off-by: Corentin Chary --- ui/vnc.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index 90b6384..3138053 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2414,6 +2414,9 @@ static int vnc_refresh_server_surface(VncDisplay *vd) * Update server dirty map. */ cmp_bytes = 16 * ds_get_bytes_per_pixel(vd->ds); + if (cmp_bytes > vd->ds->surface->linesize) { + cmp_bytes = vd->ds->surface->linesize; + } guest_row = vd->guest.ds->data; server_row = vd->server->data; for (y = 0; y < vd->guest.ds->height; y++) { -- 1.7.3.4