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
This commit is contained in:
parent
241a3b76d8
commit
1464f257c1
@ -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, int freq, int flags)
|
||||
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, const u_int8_t *essid, size_t essid_len)
|
||||
{
|
||||
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 *ik)
|
||||
break;
|
||||
}
|
||||
if (printcontents) {
|
||||
int i;
|
||||
u_int i;
|
||||
|
||||
printf(" <");
|
||||
for (i = 0; i < keylen; i++)
|
||||
|
Loading…
Reference in New Issue
Block a user