MFC 1.44: treat setting the optional ie to a zero-length datum to

mean "delete the ie"

Approved by:	re (scottl)
This commit is contained in:
sam 2006-02-23 02:03:39 +00:00
parent 34436ebdd7
commit 44cbc2ce07

View File

@ -1515,7 +1515,7 @@ static int
ieee80211_ioctl_setoptie(struct ieee80211com *ic, struct ieee80211req *ireq)
{
int error;
void *ie;
void *ie, *oie;
/*
* NB: Doing this for ap operation could be useful (e.g. for
@ -1527,15 +1527,25 @@ ieee80211_ioctl_setoptie(struct ieee80211com *ic, struct ieee80211req *ireq)
return EINVAL;
if (ireq->i_len > IEEE80211_MAX_OPT_IE)
return EINVAL;
MALLOC(ie, void *, ireq->i_len, M_DEVBUF, M_NOWAIT);
if (ie == NULL)
return ENOMEM;
error = copyin(ireq->i_data, ie, ireq->i_len);
if (ireq->i_len > 0) {
MALLOC(ie, void *, ireq->i_len, M_DEVBUF, M_NOWAIT);
if (ie == NULL)
return ENOMEM;
error = copyin(ireq->i_data, ie, ireq->i_len);
if (error) {
FREE(ie, M_DEVBUF);
return error;
}
} else {
ie = NULL;
ireq->i_len = 0;
}
/* XXX sanity check data? */
if (ic->ic_opt_ie != NULL)
FREE(ic->ic_opt_ie, M_DEVBUF);
oie = ic->ic_opt_ie;
ic->ic_opt_ie = ie;
ic->ic_opt_ie_len = ireq->i_len;
if (oie != NULL)
FREE(oie, M_DEVBUF);
return 0;
}