diff options
author | Stanislaw Gruszka <sgruszka@redhat.com> | 2012-03-29 10:30:41 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-04-10 15:20:28 -0400 |
commit | 88c868c43ba38ac3bab07bab4c45b4bc44c94357 (patch) | |
tree | c56c66967ebb4a33142a54ef94396340656399bf | |
parent | 32c5057b22a60b23353dda93c57e475856ca286c (diff) |
mac80211: sanity check for null SSID
While associated we should never have empty SSID, but life can be full
of surprises, and is allways better to print a warning than crash.
Before memcpy() in ieee80211_probereq_get() check ssid_len instead of
ssid pointer, sice pointer it always passed by "ssidie + 2" expression
to send probe functions, so practically never can be NULL.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | net/mac80211/mlme.c | 19 | ||||
-rw-r--r-- | net/mac80211/tx.c | 2 |
2 files changed, 17 insertions, 4 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 93d484c8a0b8..12ca9820689a 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -1518,9 +1518,16 @@ static void ieee80211_mgd_probe_ap_send(struct ieee80211_sub_if_data *sdata) | |||
1518 | ifmgd->nullfunc_failed = false; | 1518 | ifmgd->nullfunc_failed = false; |
1519 | ieee80211_send_nullfunc(sdata->local, sdata, 0); | 1519 | ieee80211_send_nullfunc(sdata->local, sdata, 0); |
1520 | } else { | 1520 | } else { |
1521 | int ssid_len; | ||
1522 | |||
1521 | ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID); | 1523 | ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID); |
1522 | ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid[1], NULL, 0, | 1524 | if (WARN_ON_ONCE(ssid == NULL)) |
1523 | (u32) -1, true, false); | 1525 | ssid_len = 0; |
1526 | else | ||
1527 | ssid_len = ssid[1]; | ||
1528 | |||
1529 | ieee80211_send_probe_req(sdata, dst, ssid + 2, ssid_len, NULL, | ||
1530 | 0, (u32) -1, true, false); | ||
1524 | } | 1531 | } |
1525 | 1532 | ||
1526 | ifmgd->probe_send_count++; | 1533 | ifmgd->probe_send_count++; |
@@ -1596,6 +1603,7 @@ struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw, | |||
1596 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; | 1603 | struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; |
1597 | struct sk_buff *skb; | 1604 | struct sk_buff *skb; |
1598 | const u8 *ssid; | 1605 | const u8 *ssid; |
1606 | int ssid_len; | ||
1599 | 1607 | ||
1600 | if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) | 1608 | if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) |
1601 | return NULL; | 1609 | return NULL; |
@@ -1606,8 +1614,13 @@ struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw, | |||
1606 | return NULL; | 1614 | return NULL; |
1607 | 1615 | ||
1608 | ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID); | 1616 | ssid = ieee80211_bss_get_ie(ifmgd->associated, WLAN_EID_SSID); |
1617 | if (WARN_ON_ONCE(ssid == NULL)) | ||
1618 | ssid_len = 0; | ||
1619 | else | ||
1620 | ssid_len = ssid[1]; | ||
1621 | |||
1609 | skb = ieee80211_build_probe_req(sdata, ifmgd->associated->bssid, | 1622 | skb = ieee80211_build_probe_req(sdata, ifmgd->associated->bssid, |
1610 | (u32) -1, ssid + 2, ssid[1], | 1623 | (u32) -1, ssid + 2, ssid_len, |
1611 | NULL, 0, true); | 1624 | NULL, 0, true); |
1612 | 1625 | ||
1613 | return skb; | 1626 | return skb; |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 14a01c81f959..e0b89780b472 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -2602,7 +2602,7 @@ struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw, | |||
2602 | pos = skb_put(skb, ie_ssid_len); | 2602 | pos = skb_put(skb, ie_ssid_len); |
2603 | *pos++ = WLAN_EID_SSID; | 2603 | *pos++ = WLAN_EID_SSID; |
2604 | *pos++ = ssid_len; | 2604 | *pos++ = ssid_len; |
2605 | if (ssid) | 2605 | if (ssid_len) |
2606 | memcpy(pos, ssid, ssid_len); | 2606 | memcpy(pos, ssid, ssid_len); |
2607 | pos += ssid_len; | 2607 | pos += ssid_len; |
2608 | 2608 | ||