From: Jo-Philipp Wich Date: Tue, 17 Dec 2013 17:50:42 +0000 (+0000) Subject: Properly check strtol() results when paring values as integers X-Git-Url: http://git.archive.openwrt.org/?p=project%2Ffirewall3.git;a=commitdiff_plain;h=a25bb666ddff27f2a541a29aff759081961b9de1;ds=sidebyside Properly check strtol() results when paring values as integers --- diff --git a/options.c b/options.c index c212218..7e62ca6 100644 --- a/options.c +++ b/options.c @@ -142,9 +142,10 @@ fw3_parse_bool(void *ptr, const char *val, bool is_list) bool fw3_parse_int(void *ptr, const char *val, bool is_list) { - int n = strtol(val, NULL, 0); + char *e; + int n = strtol(val, &e, 0); - if (errno == ERANGE || errno == EINVAL) + if (e == val || *e) return false; *((int *)ptr) = n;