qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] monitor: fix parsing of big int


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] monitor: fix parsing of big int
Date: Thu, 01 Aug 2013 07:52:17 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

On 08/01/2013 12:31 AM, Fam Zheng wrote:
> Fix it by calling strtoll instead, which will report ERANGE as expected.
> 
>     (HMP) block_set_io_throttle ide0-hd0 999999999999999999 0 0 0 0 0
>     (HMP) block_set_io_throttle ide0-hd0 9999999999999999999 0 0 0 0 0
>     number too large
>     (HMP) block_set_io_throttle ide0-hd0 99999999999999999999 0 0 0 0 0
>     number too large

Your change causes this error message:
(HMP) block_set_io_throttle ide0-hd0 -99999999999999999999 0 0 0 0 0
number too large

Does the "too large" mean in magnitude (correct message) or in value
(misleading message, as any negative number is smaller in value than our
minimum of 0)?

> 
> Signed-off-by: Fam Zheng <address@hidden>
> ---
>  monitor.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 5dc0aa9..7bfb469 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -3286,7 +3286,7 @@ static int64_t expr_unary(Monitor *mon)
>          break;
>      default:
>          errno = 0;
> -        n = strtoull(pch, &p, 0);
> +        n = strtoll(pch, &p, 0);

I'm worried that this will break callers that treat their argument as
unsigned, and where the full range of unsigned input was desirable.  At
this point, it's probably safer to do a case-by-case analysis of all
callers that use expr_unary() to decide which callers must reject
negative values, instead of making the parser reject numbers that it
previously accepted, thus changing the behavior of callers that treated
the result as unsigned.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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