From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HaihB-00052d-EA for qemu-devel@nongnu.org; Sun, 08 Apr 2007 21:29:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Haih9-00052R-TU for qemu-devel@nongnu.org; Sun, 08 Apr 2007 21:29:25 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Haih9-00052O-Nx for qemu-devel@nongnu.org; Sun, 08 Apr 2007 21:29:23 -0400 Received: from vms048pub.verizon.net ([206.46.252.48]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HaidN-0002ed-Iv for qemu-devel@nongnu.org; Sun, 08 Apr 2007 21:25:29 -0400 Received: from localhost ([68.163.149.131]) by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JG700AKUILB5627@vms048.mailsrvcs.net> for qemu-devel@nongnu.org; Sun, 08 Apr 2007 20:24:48 -0500 (CDT) Date: Sun, 08 Apr 2007 21:25:10 -0400 From: Thomas Tuttle Subject: Re: [Qemu-devel] [PATCH][UPDATED] Crop VNC update requests to avoid segfaults In-reply-to: <46199109.2070401@codemonkey.ws> Message-id: <20070409012510.GA4439@lion> MIME-version: 1.0 Content-type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary=EuxKj2iCbKjpUGkD Content-disposition: inline References: <20070409004011.GA1570@lion> <46199109.2070401@codemonkey.ws> 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 --EuxKj2iCbKjpUGkD Content-Type: multipart/mixed; boundary="vtzGhvizbBRQ85DL" Content-Disposition: inline --vtzGhvizbBRQ85DL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On April 08 at 21:04 EDT, Anthony Liguori hastily scribbled: > Thomas Tuttle wrote: > >+ if (x_position > vs->ds->width) x_position =3D vs->ds->width; > >+ if (y_position > vs->ds->height) y_position =3D vs->ds->height; > >+ if (x_position + w >=3D vs->ds->width) w =3D vs->ds->width - x_po= sition; > >+ if (y_position + h >=3D vs->ds->height) h =3D vs->ds->height - y_po= sition; > >+ if (w < 0) w =3D 0; > >+ if (h < 0) h =3D 0; >=20 > These last two lines aren't strictly needed since x_position cannot be >= =20 > than vs->ds->width due to the first check but otherwise the patch looks= =20 > good. You're right. I've attached a new version of the patch. --Thomas Tuttle --vtzGhvizbBRQ85DL Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="qemu-crop-vnc-update.patch" Index: vnc.c =================================================================== RCS file: /sources/qemu/qemu/vnc.c,v retrieving revision 1.13 diff -u -r1.13 vnc.c --- vnc.c 19 Mar 2007 15:17:08 -0000 1.13 +++ vnc.c 9 Apr 2007 01:24:19 -0000 @@ -852,6 +852,11 @@ int x_position, int y_position, int w, int h) { + if (x_position > vs->ds->width) x_position = vs->ds->width; + if (y_position > vs->ds->height) y_position = vs->ds->height; + if (x_position + w >= vs->ds->width) w = vs->ds->width - x_position; + if (y_position + h >= vs->ds->height) h = vs->ds->height - y_position; + int i; vs->need_update = 1; if (!incremental) { --vtzGhvizbBRQ85DL-- --EuxKj2iCbKjpUGkD Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFGGZX2/UG6u69REsYRAtGpAJ0QrQrlY758BoWXgCfHvBzOevT/6ACaA9ja JGFdhLkSnSu8WNckr3QDQMo= =u9vf -----END PGP SIGNATURE----- --EuxKj2iCbKjpUGkD--