[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: |
Luiz Capitulino |
Subject: |
Re: [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in strtoul() |
Date: |
Thu, 26 Apr 2012 20:14:45 -0300 |
On Thu, 26 Apr 2012 22:30:20 +0100
Peter Maydell <address@hidden> wrote:
> On 26 April 2012 22:10, Luiz Capitulino <address@hidden> wrote:
> > It's not checked currently, so something like:
> >
> > (qemu) balloon -100000000000001111114334234
> > (qemu)
> >
> > Will just "work" (in this case the balloon command will get a random
> > value).
> >
> > Fix it by checking if strtout() overflowed.
>
> "strtoul()/strtoull()".
Ah, thanks.
>
> > Signed-off-by: Luiz Capitulino <address@hidden>
> > ---
> > monitor.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/monitor.c b/monitor.c
> > index 8946a10..6178f48 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -3122,8 +3122,14 @@ static int64_t expr_unary(Monitor *mon)
> > default:
> > #if TARGET_PHYS_ADDR_BITS > 32
> > n = strtoull(pch, &p, 0);
> > + if (n == ULLONG_MAX && errno == ERANGE) {
> > + expr_error(mon, "error: too long number");
> > + }
> > #else
> > n = strtoul(pch, &p, 0);
> > + if (n == ULONG_MAX && errno == ERANGE) {
> > + expr_error(mon, "error: too long number");
> > + }
> > #endif
> > if (pch == p) {
> > expr_error(mon, "invalid char in expression");
>
> None of the other expr_error()s here say "error: ", so
> for consistency this one shouldn't either.
> Also, perhaps "number out of range" or "number too large"
> would sound better?
Agree, will make the change.
[Qemu-devel] [PATCH 2/2] hmp: fix bad value conversion for M type, Luiz Capitulino, 2012/04/26