[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 23/29] monitor: fail when 'i' type is greater th

From: Avi Kivity
Subject: [Qemu-devel] Re: [PATCH 23/29] monitor: fail when 'i' type is greater than 32-bit
Date: Thu, 13 Aug 2009 17:43:40 +0300
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Lightning/1.0pre Thunderbird/3.0b2

On 08/13/2009 05:18 PM, Luiz Capitulino wrote:
On Thu, 13 Aug 2009 16:59:46 +0300
Avi Kivity<address@hidden>  wrote:

On 08/13/2009 04:50 PM, Luiz Capitulino wrote:
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<address@hidden>
   monitor.c |    6 ++++++
   1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/monitor.c b/monitor.c
index e736de4..2052c00 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2820,6 +2820,12 @@ static const mon_cmd_t *monitor_parse_command(Monitor 
                   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));

What about the commands that do allow 64-bit values, like memory inspection?

  They work with the long type ('l'), so the check will be false
as it checks for 'i'.

Ah, ok.

error compiling committee.c: too many arguments to function

reply via email to

[Prev in Thread] Current Thread [Next in Thread]