From owner-svn-src-head@freebsd.org Mon Apr 25 00:41:25 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3A19CB1C7D1; Mon, 25 Apr 2016 00:41:25 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D901513E4; Mon, 25 Apr 2016 00:41:24 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3P0fOH3024583; Mon, 25 Apr 2016 00:41:24 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3P0fOte024582; Mon, 25 Apr 2016 00:41:24 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201604250041.u3P0fOte024582@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 25 Apr 2016 00:41:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298556 - head/sbin/ifconfig X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Apr 2016 00:41:25 -0000 Author: pfg Date: Mon Apr 25 00:41:23 2016 New Revision: 298556 URL: https://svnweb.freebsd.org/changeset/base/298556 Log: ifconfig: prevent some improbable signed integer overflows. ic_nchans, from struct:ieee80211req_chaninfo, is an unsigned int. Use an unsigned index to prevent overflowing the index. Adopt unsigned integers in other cases where it is useful to be aware of the unsigned quantities and there is no risk of the values being negative. MFC after: 1 week Modified: head/sbin/ifconfig/ifieee80211.c Modified: head/sbin/ifconfig/ifieee80211.c ============================================================================== --- head/sbin/ifconfig/ifieee80211.c Sun Apr 24 22:13:55 2016 (r298555) +++ head/sbin/ifconfig/ifieee80211.c Mon Apr 25 00:41:23 2016 (r298556) @@ -225,7 +225,7 @@ static int canpromote(int i, int from, int to) { const struct ieee80211_channel *fc = &chaninfo->ic_chans[i]; - int j; + u_int j; if ((fc->ic_flags & from) != from) return i; @@ -304,7 +304,7 @@ promote(int i) static void mapfreq(struct ieee80211_channel *chan, int freq, int flags) { - int i; + u_int i; for (i = 0; i < chaninfo->ic_nchans; i++) { const struct ieee80211_channel *c = &chaninfo->ic_chans[i]; @@ -324,7 +324,7 @@ mapfreq(struct ieee80211_channel *chan, static void mapchan(struct ieee80211_channel *chan, int ieee, int flags) { - int i; + u_int i; for (i = 0; i < chaninfo->ic_nchans; i++) { const struct ieee80211_channel *c = &chaninfo->ic_chans[i]; @@ -3047,7 +3047,7 @@ copy_essid(char buf[], size_t bufsize, c { const u_int8_t *p; size_t maxlen; - int i; + u_int i; if (essid_len > bufsize) maxlen = bufsize; @@ -4251,7 +4251,7 @@ static void printkey(const struct ieee80211req_key *ik) { static const uint8_t zerodata[IEEE80211_KEYBUF_SIZE]; - int keylen = ik->ik_keylen; + u_int keylen = ik->ik_keylen; int printcontents; printcontents = printkeys && @@ -4288,7 +4288,7 @@ printkey(const struct ieee80211req_key * break; } if (printcontents) { - int i; + u_int i; printf(" <"); for (i = 0; i < keylen; i++)