From patchwork Wed Aug 19 23:07:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 31696 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id BFBBFB7067 for ; Thu, 20 Aug 2009 09:52:21 +1000 (EST) Received: from localhost ([127.0.0.1]:58231 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mduwz-0006SP-PA for incoming@patchwork.ozlabs.org; Wed, 19 Aug 2009 19:52:17 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MduHs-0002b7-E7 for qemu-devel@nongnu.org; Wed, 19 Aug 2009 19:09:48 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MduHn-0002XW-O1 for qemu-devel@nongnu.org; Wed, 19 Aug 2009 19:09:47 -0400 Received: from [199.232.76.173] (port=49915 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MduHn-0002XF-Hb for qemu-devel@nongnu.org; Wed, 19 Aug 2009 19:09:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46889) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MduHm-0005be-Sk for qemu-devel@nongnu.org; Wed, 19 Aug 2009 19:09:43 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7JN9fX2003461; Wed, 19 Aug 2009 19:09:41 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7JN9e5d031088; Wed, 19 Aug 2009 19:09:40 -0400 Received: from localhost (vpn-10-5.bos.redhat.com [10.16.10.5]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n7JN9cUf032038; Wed, 19 Aug 2009 19:09:39 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Wed, 19 Aug 2009 20:07:54 -0300 Message-Id: <1250723280-3509-24-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1250723280-3509-1-git-send-email-lcapitulino@redhat.com> References: <1250723280-3509-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, avi@redhat.com Subject: [Qemu-devel] [PATCH 23/29] monitor: fail when 'i' type is greater than 32-bit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The 'i' argument type is for 32-bit only and most handlers will use an 'int' to store its value. It's better to fail gracefully when the user enters a value greater than 32-bit than to get subtle casting bugs. Signed-off-by: Luiz Capitulino --- monitor.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/monitor.c b/monitor.c index b067b24..519bae0 100644 --- a/monitor.c +++ b/monitor.c @@ -2820,6 +2820,12 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, } if (get_expr(mon, &val, &p)) goto fail; + /* Check if 'i' is greater than 32-bit */ + if ((c == 'i') && ((val >> 32) & 0xffffffff)) { + monitor_printf(mon, "\'%s\' has failed: ", cmdname); + monitor_printf(mon, "integer is for 32-bit values\n"); + goto fail; + } qdict_add_qint(qdict, key, qint_from_int64(val)); } break;