From 572dcc2b8397b149fab16a2e885598b59691ad47 Mon Sep 17 00:00:00 2001 From: Robert Ransom Date: Sun, 20 May 2012 12:51:18 +0000 Subject: [PATCH] util/estrtol: Also check for out-of-range values using errno --- util/estrtol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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