Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Dec 2008 01:10:08 +0000 (UTC)
From:      Sam Leffler <sam@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r186103 - head/sbin/ifconfig
Message-ID:  <200812150110.mBF1A8g3079693@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812150110.mBF1A8g3079693>