POSIXed strtoll() (and ours one too) can set errno to EINVAL, so check

it first.

Approved by:    andre
This commit is contained in:
Andrey A. Chernov 2006-03-14 19:53:03 +00:00
parent 9e92c8d486
commit 7768950fe3

View File

@ -51,7 +51,7 @@ strtonum(const char *numstr, long long minval, long long maxval,
error = INVALID;
else {
ll = strtoll(numstr, &ep, 10);
if (numstr == ep || *ep != '\0')
if (errno == EINVAL || numstr == ep || *ep != '\0')
error = INVALID;
else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval)
error = TOOSMALL;