From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MgLxs-00040N-OA for qemu-devel@nongnu.org; Wed, 26 Aug 2009 13:07:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MgLxo-0003wF-Vq for qemu-devel@nongnu.org; Wed, 26 Aug 2009 13:07:16 -0400 Received: from [199.232.76.173] (port=45833 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgLxo-0003vo-LG for qemu-devel@nongnu.org; Wed, 26 Aug 2009 13:07:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17990) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MgLxn-0000qv-V1 for qemu-devel@nongnu.org; Wed, 26 Aug 2009 13:07:12 -0400 From: Luiz Capitulino Date: Wed, 26 Aug 2009 14:05:46 -0300 Message-Id: <1251306352-31316-24-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1251306352-31316-1-git-send-email-lcapitulino@redhat.com> References: <1251306352-31316-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PATCH 23/29] monitor: fail when 'i' type is greater than 32-bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, avi@redhat.com 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 68fbf34..2932f0b 100644 --- a/monitor.c +++ b/monitor.c @@ -2748,6 +2748,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_put(qdict, key, qint_from_int(val)); } break; -- 1.6.4.1.184.g2e117