From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhBKo-0008JN-Ef for qemu-devel@nongnu.org; Wed, 30 Sep 2015 02:57:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhBKj-0005HG-4V for qemu-devel@nongnu.org; Wed, 30 Sep 2015 02:57:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35344) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhBKi-0005H8-Uy for qemu-devel@nongnu.org; Wed, 30 Sep 2015 02:57:45 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 01328C0B1B42 for ; Wed, 30 Sep 2015 06:57:43 +0000 (UTC) From: Gerd Hoffmann Date: Wed, 30 Sep 2015 08:57:31 +0200 Message-Id: <1443596251-27498-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH] vmsvga: more cursor checks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Check the cursor size more carefully. Also switch to unsigned while being at it, so they can't be negative. Signed-off-by: Gerd Hoffmann --- hw/display/vmware_vga.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index 8e93509..9354037 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -488,10 +488,10 @@ static inline int vmsvga_fill_rect(struct vmsvga_state_s *s, #endif struct vmsvga_cursor_definition_s { - int width; - int height; + uint32_t width; + uint32_t height; int id; - int bpp; + uint32_t bpp; int hot_x; int hot_y; uint32_t mask[1024]; @@ -658,7 +658,10 @@ static void vmsvga_fifo_run(struct vmsvga_state_s *s) cursor.bpp = vmsvga_fifo_read(s); args = SVGA_BITMAP_SIZE(x, y) + SVGA_PIXMAP_SIZE(x, y, cursor.bpp); - if (SVGA_BITMAP_SIZE(x, y) > sizeof cursor.mask || + if (cursor.width > 256 || + cursor.height > 256 || + cursor.bpp > 32 || + SVGA_BITMAP_SIZE(x, y) > sizeof cursor.mask || SVGA_PIXMAP_SIZE(x, y, cursor.bpp) > sizeof cursor.image) { goto badcmd; } -- 1.8.3.1