From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxHuZ-00043U-2u for qemu-devel@nongnu.org; Wed, 18 Jun 2014 11:36:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxHuR-0003m2-H1 for qemu-devel@nongnu.org; Wed, 18 Jun 2014 11:36:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxHuR-0003lw-9J for qemu-devel@nongnu.org; Wed, 18 Jun 2014 11:36:23 -0400 Date: Wed, 18 Jun 2014 18:36:46 +0300 From: "Michael S. Tsirkin" Message-ID: <1403105798-25418-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] qapi: fix input visitor bugs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Michael Roth , Luiz Capitulino Remove dead code. Reset errno to 0 before each strtoull call, as the man page requires. Reported-by: Eric Blake Signed-off-by: Michael S. Tsirkin --- qapi/string-input-visitor.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c index 72722e6..d8a8db0 100644 --- a/qapi/string-input-visitor.c +++ b/qapi/string-input-visitor.c @@ -48,11 +48,10 @@ static void parse_str(StringInputVisitor *siv, Error **errp) return; } - errno = 0; do { + errno = 0; start = strtoll(str, &endptr, 0); - if (errno == 0 && endptr > str && INT64_MIN <= start && - start <= INT64_MAX) { + if (errno == 0 && endptr > str) { if (*endptr == '\0') { cur = g_malloc0(sizeof(*cur)); cur->begin = start; @@ -63,9 +62,9 @@ static void parse_str(StringInputVisitor *siv, Error **errp) str = NULL; } else if (*endptr == '-') { str = endptr + 1; + errno = 0; end = strtoll(str, &endptr, 0); - if (errno == 0 && endptr > str && - INT64_MIN <= end && end <= INT64_MAX && start <= end && + if (errno == 0 && endptr > str && start <= end && (start > INT64_MAX - 65536 || end < start + 65536)) { if (*endptr == '\0') { -- MST