From 4b8740cd0af0f2177bae523857ee5ce65071e9a9 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Thu, 25 Sep 2014 22:47:19 +0000 Subject: [PATCH] Explicitly set errno to 0 before calling strto*. Suggested by: mjg MFC after: 2 weeks --- sbin/sysctl/sysctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index d7fe8e91356..5ebec28c18a 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -294,6 +294,8 @@ parse(const char *string, int lineno) } } + errno = 0; + switch (kind & CTLTYPE) { case CTLTYPE_INT: if (strcmp(fmt, "IK") == 0) { @@ -673,6 +675,7 @@ set_IK(const char *str, int *val) if ((len = strlen(str)) == 0) return (0); p = &str[len - 1]; + errno = 0; if (*p == 'C' || *p == 'F') { temp = strtof(str, &endptr); if (errno != 0 || endptr == str ||