[Top][All Lists]
[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.
[...]
- [Qemu-devel] [PATCH v2 0/2]: hmp: integer parsing fixes, Luiz Capitulino, 2012/04/26
- [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in strtoul()/strtoull(), Luiz Capitulino, 2012/04/26
- Re: [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in strtoul()/strtoull(), Markus Armbruster, 2012/04/27
- Re: [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in strtoul()/strtoull(), Eric Blake, 2012/04/27
- Re: [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in strtoul()/strtoull(), Luiz Capitulino, 2012/04/27
- Re: [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in strtoul()/strtoull(),
Markus Armbruster <=
- Re: [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in strtoul()/strtoull(), Luiz Capitulino, 2012/04/27
- Re: [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in strtoul()/strtoull(), Eric Blake, 2012/04/27
- Re: [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in strtoul()/strtoull(), Luiz Capitulino, 2012/04/27
- Re: [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in strtoul()/strtoull(), Markus Armbruster, 2012/04/27
- [Qemu-devel] [PATCH 2/2] hmp: fix bad value conversion for M type, Luiz Capitulino, 2012/04/26