Received: from [140.186.70.92] (port=47688 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q8gTV-0008Ip-Ik for qemu-devel@nongnu.org; Sat, 09 Apr 2011 18:17:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q8gTU-0004cS-Es for qemu-devel@nongnu.org; Sat, 09 Apr 2011 18:17:49 -0400 Received: from hall.aurel32.net ([88.191.126.93]:46002) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q8gTU-0004c9-4R for qemu-devel@nongnu.org; Sat, 09 Apr 2011 18:17:48 -0400 Date: Sun, 10 Apr 2011 00:17:39 +0200 From: Aurelien Jarno Subject: Re: [Qemu-devel] [PATCH 4/4] vnc: Limit r/w access to size of allocated memory Message-ID: <20110409221739.GB11487@volta.aurel32.net> References: <1300696478-6051-1-git-send-email-corentin.chary@gmail.com> <1300696478-6051-5-git-send-email-corentin.chary@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1300696478-6051-5-git-send-email-corentin.chary@gmail.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Corentin Chary Cc: Blue Swirl , Paolo Bonzini , Anthony Liguori , qemu-devel On Mon, Mar 21, 2011 at 09:34:38AM +0100, Corentin Chary wrote: > 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; > + } What about using ds_get_linesize(vd->ds) instead? > guest_row = vd->guest.ds->data; > server_row = vd->server->data; > for (y = 0; y < vd->guest.ds->height; y++) { > -- > 1.7.3.4 > > > -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net