summaryrefslogtreecommitdiffstats
path: root/src/parse.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-06-04 12:51:12 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-06-04 12:51:12 -0400
commit3da7fe8b4f5d6a41152d81bbfbd30b0ab3a9da1c (patch)
treee675798b2918c477cbbf69707a1d2f32120cd3df /src/parse.c
parent32d252598e855829ebdc657e635f93270600b5a2 (diff)
downloadbfs-3da7fe8b4f5d6a41152d81bbfbd30b0ab3a9da1c.tar.xz
bfstd: New xstrtoll() wrapper
Diffstat (limited to 'src/parse.c')
-rw-r--r--src/parse.c17
1 files changed, 2 insertions, 15 deletions
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;
}