diff options
author | sam <sam@FreeBSD.org> | 2008-12-15 01:10:08 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2008-12-15 01:10:08 +0000 |
commit | b076937b92ede3c993ce0b748b1b9ae4014cbefc (patch) | |
tree | 62d0d6c0d4d2cfe3bd36fab766462604638d44cc /sbin/ifconfig | |
parent | 4cd355eb2dfe0fcc9013eed1f70816aad6dbebf6 (diff) | |
download | FreeBSD-src-b076937b92ede3c993ce0b748b1b9ae4014cbefc.zip FreeBSD-src-b076937b92ede3c993ce0b748b1b9ae4014cbefc.tar.gz |
fix handling of unknown country codes; atoi doesn't return -1
for an invalid string as I thought; so use strtol instead
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r-- | sbin/ifconfig/ifieee80211.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c index 950d3bd..e7984f5 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); |