diff --git a/util/estrtol.c b/util/estrtol.c index 26c1fde..431b40c 100644 --- a/util/estrtol.c +++ b/util/estrtol.c @@ -1,4 +1,5 @@ /* See LICENSE file for copyright and license details. */ +#include #include #include #include "../util.h" @@ -9,8 +10,9 @@ estrtol(const char *s, int base) char *end; long n; + errno = 0; n = strtol(s, &end, base); - if(*end != '\0') { + if(*end != '\0' || errno != 0) { if(base == 0) eprintf("%s: not an integer\n", s); else