Skip to content

Commit

Permalink
mac80211: fix mesh_add_rsn_ie IE finding loop
Browse files Browse the repository at this point in the history
Previously, the code to copy the RSN IE from the mesh config
would increment its pointer by one in the loop instead of by
the element length, so there was the potential for mistaking
another IE's data fields as the RSN IE.

cfg80211_find_ie() exists, so just use that.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Bob Copeland authored and Johannes Berg committed Apr 22, 2014
1 parent aee6499 commit a40a8c1
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions net/mac80211/mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,20 +366,15 @@ int mesh_add_rsn_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb)
return 0;

/* find RSN IE */
data = ifmsh->ie;
while (data < ifmsh->ie + ifmsh->ie_len) {
if (*data == WLAN_EID_RSN) {
len = data[1] + 2;
break;
}
data++;
}
data = cfg80211_find_ie(WLAN_EID_RSN, ifmsh->ie, ifmsh->ie_len);
if (!data)
return 0;

if (len) {
if (skb_tailroom(skb) < len)
return -ENOMEM;
memcpy(skb_put(skb, len), data, len);
}
len = data[1] + 2;

if (skb_tailroom(skb) < len)
return -ENOMEM;
memcpy(skb_put(skb, len), data, len);

return 0;
}
Expand Down

0 comments on commit a40a8c1

Please sign in to comment.