diff options
| author | Sergey Kandaurov <pluknet@FreeBSD.org> | 2013-08-21 22:37:15 +0000 |
|---|---|---|
| committer | Sergey Kandaurov <pluknet@FreeBSD.org> | 2013-08-21 22:37:15 +0000 |
| commit | 7261b203c6223fcbb1073fee20b7bbaf8f1804aa (patch) | |
| tree | 46aa7220e77a111bb6f8179411f69c0dc730fc4d /lib/libutil | |
| parent | 5188b5f3c2d7e1c76e995fddde5a9678c3271510 (diff) | |
Notes
Diffstat (limited to 'lib/libutil')
| -rw-r--r-- | lib/libutil/expand_number.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/libutil/expand_number.c b/lib/libutil/expand_number.c index 0a62c12556a0..401e2d9ac8b6 100644 --- a/lib/libutil/expand_number.c +++ b/lib/libutil/expand_number.c @@ -50,15 +50,22 @@ int expand_number(const char *buf, uint64_t *num) { uint64_t number; + int saved_errno; unsigned shift; char *endptr; + saved_errno = errno; + errno = 0; + number = strtoumax(buf, &endptr, 0); if (number == UINTMAX_MAX && errno == ERANGE) { return (-1); } + if (errno == 0) + errno = saved_errno; + if (endptr == buf) { /* No valid digits. */ errno = EINVAL; |
