aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/util.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 3fc3716..41d8104 100644
--- a/src/util.c
+++ b/src/util.c
@@ -32,6 +32,11 @@ tollu(const char *s, unsigned long long int min, unsigned long long int max, uns
errno = ERANGE;
return -1;
}
+ if (!isdigit(s[*s == 'x' || *s == 'X' || *s == '#']) ||
+ (*s == '0' && !isdigit(s[1 + (*s == 'x' || *s == 'o' || *s == 'b')]))) {
+ errno = EINVAL;
+ return -1;
+ }
if (tolower(*s) == 'x' || *s == '#')
*out = strtoull(s + 1, &end, 16);
else if (*s == '0' && tolower(s[1]) == 'x')