From patchwork Tue Oct 20 07:42:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 532881 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 443FC1400A0 for ; Tue, 20 Oct 2015 21:41:36 +1100 (AEDT) Received: from localhost ([::1]:44339 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoRZp-0000wQ-4i for incoming@patchwork.ozlabs.org; Tue, 20 Oct 2015 03:43:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoRZL-00008F-7I for qemu-devel@nongnu.org; Tue, 20 Oct 2015 03:42:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZoRZD-0005n8-8H for qemu-devel@nongnu.org; Tue, 20 Oct 2015 03:42:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57549) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoRZC-0005mo-Te for qemu-devel@nongnu.org; Tue, 20 Oct 2015 03:42:43 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 909ADC057874 for ; Tue, 20 Oct 2015 07:42:42 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-57.ams2.redhat.com [10.36.116.57]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9K7gfh3012462; Tue, 20 Oct 2015 03:42:42 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id E1CF981B25; Tue, 20 Oct 2015 09:42:40 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 20 Oct 2015 09:42:38 +0200 Message-Id: <1445326958-28177-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1445326958-28177-1-git-send-email-kraxel@redhat.com> References: <1445326958-28177-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PULL 2/2] vmsvga: more cursor checks 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 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; }