Do not copy first keys into four key entries; the bug was introduced in 1.17

This commit is contained in:
onoe 2001-07-18 02:06:44 +00:00
parent 17538b3790
commit 69b6def907

View File

@ -1,4 +1,4 @@
/* $NetBSD: an.c,v 1.19 2001/07/07 15:53:17 thorpej Exp $ */ /* $NetBSD: an.c,v 1.20 2001/07/18 02:06:44 onoe Exp $ */
/* /*
* Copyright (c) 1997, 1998, 1999 * Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
@ -653,24 +653,24 @@ static int
an_set_nwkey_wep(struct an_softc *sc, struct ieee80211_nwkey *nwkey) an_set_nwkey_wep(struct an_softc *sc, struct ieee80211_nwkey *nwkey)
{ {
int i, txkey, anysetkey, needreset, error; int i, txkey, anysetkey, needreset, error;
struct an_wepkey keys[IEEE80211_WEP_NKID], *key; struct an_wepkey keys[IEEE80211_WEP_NKID];
error = 0; error = 0;
memset(keys, 0, sizeof(keys)); memset(keys, 0, sizeof(keys));
anysetkey = needreset = 0; anysetkey = needreset = 0;
/* load argument and sanity check */ /* load argument and sanity check */
for (i = 0, key = keys; i < IEEE80211_WEP_NKID; i++, key++) { for (i = 0; i < IEEE80211_WEP_NKID; i++) {
key->an_wep_keylen = nwkey->i_key[i].i_keylen; keys[i].an_wep_keylen = nwkey->i_key[i].i_keylen;
if (key->an_wep_keylen < 0) if (keys[i].an_wep_keylen < 0)
continue; continue;
if (key->an_wep_keylen != 0 && if (keys[i].an_wep_keylen != 0 &&
key->an_wep_keylen < IEEE80211_WEP_KEYLEN) keys[i].an_wep_keylen < IEEE80211_WEP_KEYLEN)
return EINVAL; return EINVAL;
if (key->an_wep_keylen > sizeof(key->an_wep_key)) if (keys[i].an_wep_keylen > sizeof(keys[i].an_wep_key))
return EINVAL; return EINVAL;
if ((error = copyin(nwkey->i_key[i].i_keydat, if ((error = copyin(nwkey->i_key[i].i_keydat,
key->an_wep_key, key->an_wep_keylen)) != 0) keys[i].an_wep_key, keys[i].an_wep_keylen)) != 0)
return error; return error;
anysetkey++; anysetkey++;
} }
@ -688,10 +688,10 @@ an_set_nwkey_wep(struct an_softc *sc, struct ieee80211_nwkey *nwkey)
if (!(nwkey->i_wepon & IEEE80211_NWKEY_PERSIST)) { if (!(nwkey->i_wepon & IEEE80211_NWKEY_PERSIST)) {
/* set temporary keys */ /* set temporary keys */
sc->an_tx_key = txkey; sc->an_tx_key = txkey;
for (i = 0, key = keys; i < IEEE80211_WEP_NKID; i++, key++) { for (i = 0; i < IEEE80211_WEP_NKID; i++) {
if (keys[i].an_wep_keylen < 0) if (keys[i].an_wep_keylen < 0)
continue; continue;
memcpy(&sc->an_wepkeys[i], keys, sizeof(*keys)); memcpy(&sc->an_wepkeys[i], &keys[i], sizeof(keys[i]));
} }
} else { } else {
/* set persist keys */ /* set persist keys */