From fd7d22e698e8d06ccf08bc25b2fe2445b4c19137 Mon Sep 17 00:00:00 2001 From: pluknet Date: Wed, 21 Aug 2013 16:46:06 +0000 Subject: [PATCH] Check strtoumax(3) for ERANGE in case of non-prefixed string. OK'd by: silence on current@ MFC after: 1 week --- lib/libutil/expand_number.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/libutil/expand_number.c b/lib/libutil/expand_number.c index 5d55884d9ac..0a62c12556a 100644 --- a/lib/libutil/expand_number.c +++ b/lib/libutil/expand_number.c @@ -55,6 +55,10 @@ expand_number(const char *buf, uint64_t *num) number = strtoumax(buf, &endptr, 0); + if (number == UINTMAX_MAX && errno == ERANGE) { + return (-1); + } + if (endptr == buf) { /* No valid digits. */ errno = EINVAL; -- 2.45.0