svn commit: r186103 - head/sbin/ifconfig

Sam Leffler sam at FreeBSD.org
Mon Dec 15 01:10:09 UTC 2008


Author: sam
Date: Mon Dec 15 01:10:08 2008
New Revision: 186103
URL: http://svn.freebsd.org/changeset/base/186103

Log:
  fix handling of unknown country codes; atoi doesn't return -1
  for an invalid string as I thought; so use strtol instead

Modified:
  head/sbin/ifconfig/ifieee80211.c

Modified: head/sbin/ifconfig/ifieee80211.c
==============================================================================
--- head/sbin/ifconfig/ifieee80211.c	Mon Dec 15 01:09:01 2008	(r186102)
+++ head/sbin/ifconfig/ifieee80211.c	Mon Dec 15 01:10:08 2008	(r186103)
@@ -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);


More information about the svn-src-all mailing list