From patchwork Tue Apr 26 08:07:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Pandit X-Patchwork-Id: 8935891 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D708C9F441 for ; Tue, 26 Apr 2016 08:07:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4801620142 for ; Tue, 26 Apr 2016 08:07:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 35E3020125 for ; Tue, 26 Apr 2016 08:07:58 +0000 (UTC) Received: from localhost ([::1]:36807 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1auy2H-0008O7-EZ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 26 Apr 2016 04:07:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1auy29-0008K8-6h for qemu-devel@nongnu.org; Tue, 26 Apr 2016 04:07:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1auy26-0001HQ-1U for qemu-devel@nongnu.org; Tue, 26 Apr 2016 04:07:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42225) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1auy25-0001HF-S9 for qemu-devel@nongnu.org; Tue, 26 Apr 2016 04:07:45 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C4474620B; Tue, 26 Apr 2016 08:07:44 +0000 (UTC) Received: from javelin.localdomain (vpn1-7-219.sin2.redhat.com [10.67.7.219]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3Q87dL1020542 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 26 Apr 2016 04:07:42 -0400 From: P J P To: Qemu Developers Date: Tue, 26 Apr 2016 13:37:38 +0530 Message-Id: <1461658058-1672-1-git-send-email-ppandit@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] display: vga: add check to limit display width X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: zuozhi.fzz@alibaba-inc.com, Gerd Hoffmann , Prasad J Pandit Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Prasad J Pandit In vga_draw_graphic, display width could exceed the maximum range of VBE_DISPI_MAX_XRES(16000). This could lead to possible integer overflows. Add check to avoid it. Reported-by: Zuozhi Fzz Signed-off-by: Prasad J Pandit --- hw/display/vga.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/display/vga.c b/hw/display/vga.c index 9f68394..1a66291 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1478,6 +1478,9 @@ static void vga_draw_graphic(VGACommonState *s, int full_update) disp_width <<= 1; } } + if (disp_width > VBE_DISPI_MAX_XRES) { + disp_width = VBE_DISPI_MAX_XRES; + } depth = s->get_bpp(s);