From patchwork Wed Mar 14 06:58:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 146560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A8D92B6EE8 for ; Wed, 14 Mar 2012 17:55:19 +1100 (EST) Received: from localhost ([::1]:36242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7i7A-0007h9-B3 for incoming@patchwork.ozlabs.org; Wed, 14 Mar 2012 02:55:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7i72-0007eY-Om for qemu-devel@nongnu.org; Wed, 14 Mar 2012 02:55:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7i6i-0007ik-FH for qemu-devel@nongnu.org; Wed, 14 Mar 2012 02:55:08 -0400 Received: from smtp5-g21.free.fr ([212.27.42.5]:44335) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7i6h-0007hl-Ro for qemu-devel@nongnu.org; Wed, 14 Mar 2012 02:54:48 -0400 Received: from localhost.localdomain (unknown [82.241.209.44]) by smtp5-g21.free.fr (Postfix) with ESMTP id B424DD48061; Wed, 14 Mar 2012 07:54:41 +0100 (CET) From: Corentin Chary To: Anthony Liguori Date: Wed, 14 Mar 2012 07:58:48 +0100 Message-Id: <1331708328-21414-3-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1331708328-21414-1-git-send-email-corentincj@iksaif.net> References: <1331708328-21414-1-git-send-email-corentincj@iksaif.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 212.27.42.5 Cc: Peter Lieven , qemu-devel@nongnu.org, kvm@vger.kernel.org, weil@mail.berlios.de Subject: [Qemu-devel] [PATCH 2/2] vnc: Limit r/w access to size of allocated memory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- ui/vnc.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index aef6d3a..deb9ecd 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2562,6 +2562,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++) {