diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-12-14 17:14:57 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-12-14 17:14:57 +0000 |
commit | 2bd5f0a63cacff999b67c3a77f99f1873ff8a205 (patch) | |
tree | 26b0d96a4a5d55b5a51f8d136fa58f444176f94b /sbin | |
parent | 034a0252a19eeacb9c170b4e9e717523762a88ed (diff) |
use strtonum() instead of atoi(). idea from Vladimir Kirillov, but had
to rewrite it because it was another mangled diff in mail. When will
people learn that the tabs and spaces are important?
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 2d67c63b398..43f7d4c7cf1 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.224 2009/12/09 21:21:57 deraadt Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.225 2009/12/14 17:14:56 deraadt Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -1713,6 +1713,7 @@ void setifchan(const char *val, int d) { struct ieee80211chanreq channel; + const char *errstr; int chan; if (val == NULL) { @@ -1724,9 +1725,9 @@ setifchan(const char *val, int d) if (d != 0) chan = IEEE80211_CHAN_ANY; else { - chan = atoi(val); - if (chan < 1 || chan > 256) { - warnx("invalid channel: %s", val); + chan = strtonum(val, 1, 256, &errstr); + if (errstr) { + warnx("invalid channel %s: %s", val, errstr); return; } } |