From c210ee95f22e90733eceeb18b9ca1914ff29e482 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 18 Jun 2014 17:50:07 +0300 Subject: qapi: fix input visitor bugs 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 Reviewed-by: Eric Blake --- qapi/string-input-visitor.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'qapi') diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c index 72722e6571..d8a8db02ed 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') { -- cgit v1.2.1