From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V55FA-0000gW-QE for qemu-devel@nongnu.org; Thu, 01 Aug 2013 22:37:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V55F3-0001Yc-Pf for qemu-devel@nongnu.org; Thu, 01 Aug 2013 22:37:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50350) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4tQl-0003TA-B0 for qemu-devel@nongnu.org; Thu, 01 Aug 2013 10:00:39 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r71E0Za4004479 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 1 Aug 2013 10:00:36 -0400 Date: Thu, 1 Aug 2013 10:00:12 -0400 From: Luiz Capitulino Message-ID: <20130801100012.5b69bc4d@redhat.com> In-Reply-To: <51FA6811.3090909@redhat.com> References: <1375338695-670-1-git-send-email-famz@redhat.com> <51FA6811.3090909@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] monitor: fix parsing of big int List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Luiz Capitulino , Fam Zheng , qemu-devel@nongnu.org On Thu, 01 Aug 2013 07:52:17 -0600 Eric Blake wrote: > 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 > > --- > > 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. > Fam, what motivated this change? Is anyone entering such big numbers for block_set_io_throttle?