From 3da7fe8b4f5d6a41152d81bbfbd30b0ab3a9da1c Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 4 Jun 2024 12:51:12 -0400 Subject: bfstd: New xstrtoll() wrapper --- src/parse.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'src/parse.c') diff --git a/src/parse.c b/src/parse.c index 3c17bc6..e1a46db 100644 --- a/src/parse.c +++ b/src/parse.c @@ -526,20 +526,14 @@ enum int_flags { * Parse an integer. */ static const char *parse_int(const struct bfs_parser *parser, char **arg, const char *str, void *result, enum int_flags flags) { - // strtoll() skips leading spaces, but we want to reject them - if (xisspace(str[0])) { - goto bad; - } - int base = flags & IF_BASE_MASK; if (base == 0) { base = 10; } char *endptr; - errno = 0; - long long value = strtoll(str, &endptr, base); - if (errno != 0) { + long long value; + if (xstrtoll(str, &endptr, base, &value) != 0) { if (errno == ERANGE) { goto range; } else { @@ -547,13 +541,6 @@ static const char *parse_int(const struct bfs_parser *parser, char **arg, const } } - // https://github.com/llvm/llvm-project/issues/64946 - sanitize_init(&endptr); - - if (endptr == str) { - goto bad; - } - if (!(flags & IF_PARTIAL_OK) && *endptr != '\0') { goto bad; } -- cgit v1.2.3