From 76f0b9bff16c450115679fb0adb319822240ac7c Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Mon, 15 Dec 2008 01:10:08 +0000 Subject: [PATCH] fix handling of unknown country codes; atoi doesn't return -1 for an invalid string as I thought; so use strtol instead --- sbin/ifconfig/ifieee80211.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c index 950d3bd3e0f6..e7984f5399a4 100644 --- a/sbin/ifconfig/ifieee80211.c +++ b/sbin/ifconfig/ifieee80211.c @@ -1982,8 +1982,12 @@ DECL_CMD_FUNC(set80211country, val, d) cc = lib80211_country_findbyname(rdp, val); if (cc == NULL) { - cc = lib80211_country_findbycc(rdp, atoi(val)); - if (cc == NULL) + char *eptr; + long code = strtol(val, &eptr, 0); + + if (eptr != val) + cc = lib80211_country_findbycc(rdp, code); + if (eptr == val || cc == NULL) errx(1, "unknown ISO country code %s", val); } getregdomain(s);