fix handling of unknown country codes; atoi doesn't return -1

for an invalid string as I thought; so use strtol instead
This commit is contained in:
Sam Leffler 2008-12-15 01:10:08 +00:00
parent b6130d380f
commit 76f0b9bff1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=186103

View File

@ -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);