qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in st


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in strtoul()/strtoull()
Date: Fri, 27 Apr 2012 15:24:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

Luiz Capitulino <address@hidden> writes:

> On Fri, 27 Apr 2012 06:22:48 -0600
> Eric Blake <address@hidden> wrote:
>
>> On 04/27/2012 03:04 AM, Markus Armbruster wrote:
>> > Luiz Capitulino <address@hidden> writes:
>> > 
>> >> It's not checked currently, so something like:
>> >>
>> 
>> >> +++ b/monitor.c
>> >> @@ -3120,10 +3120,17 @@ static int64_t expr_unary(Monitor *mon)
>> >>          n = 0;
>> >>          break;
>> >>      default:
>> >> +        errno = 0;
>> >>  #if TARGET_PHYS_ADDR_BITS > 32
>> >>          n = strtoull(pch, &p, 0);
>> >> +        if (n == ULLONG_MAX && errno == ERANGE) {
>> >> +            expr_error(mon, "number too large");
>> >> +        }
>> > 
>> > The test n == ULLONG_MAX is redundant.
>> 
>> But harmless.
>
> Yes, and I prefer to comply to the standard (as there's no strong
> reason not to do so).

What standard?

Checking errno is necessary and sufficient for detecting overflow.

[...]



reply via email to

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