aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2014-02-06 15:42:42 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-07 12:19:30 -0500
commit7a081ea20e043f243b6fb9d50448cbe757fbb860 (patch)
tree61ac41d402613b3246d01fe5fefbeb9acd5f5214
parentd3a874e899b073496d1fe89b6a2d1aa50870874d (diff)
staging: r8188eu: memory corruption handling long ssids
We should cap the SSID length at NDIS_802_11_LENGTH_SSID (32) characters to avoid memory corruption. If the SSID is too long then I have opted to ignore it instead of truncating it. We don't need to clear bssid->Ssid.Ssid[0] because this struct is allocated with rtw_zmalloc() Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_wlan_util.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c
index 153ec61493ab..96df62f95b6b 100644
--- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c
@@ -912,12 +912,12 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
912 unsigned char *pbuf; 912 unsigned char *pbuf;
913 u32 wpa_ielen = 0; 913 u32 wpa_ielen = 0;
914 u8 *pbssid = GetAddr3Ptr(pframe); 914 u8 *pbssid = GetAddr3Ptr(pframe);
915 u32 hidden_ssid = 0;
916 struct HT_info_element *pht_info = NULL; 915 struct HT_info_element *pht_info = NULL;
917 struct rtw_ieee80211_ht_cap *pht_cap = NULL; 916 struct rtw_ieee80211_ht_cap *pht_cap = NULL;
918 u32 bcn_channel; 917 u32 bcn_channel;
919 unsigned short ht_cap_info; 918 unsigned short ht_cap_info;
920 unsigned char ht_info_infos_0; 919 unsigned char ht_info_infos_0;
920 int ssid_len;
921 921
922 if (is_client_associated_to_ap(Adapter) == false) 922 if (is_client_associated_to_ap(Adapter) == false)
923 return true; 923 return true;
@@ -999,21 +999,15 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len)
999 } 999 }
1000 1000
1001 /* checking SSID */ 1001 /* checking SSID */
1002 ssid_len = 0;
1002 p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); 1003 p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_);
1003 if (p == NULL) { 1004 if (p) {
1004 DBG_88E("%s marc: cannot find SSID for survey event\n", __func__); 1005 ssid_len = *(p + 1);
1005 hidden_ssid = true; 1006 if (ssid_len > NDIS_802_11_LENGTH_SSID)
1006 } else { 1007 ssid_len = 0;
1007 hidden_ssid = false;
1008 }
1009
1010 if ((NULL != p) && (false == hidden_ssid && (*(p + 1)))) {
1011 memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1));
1012 bssid->Ssid.SsidLength = *(p + 1);
1013 } else {
1014 bssid->Ssid.SsidLength = 0;
1015 bssid->Ssid.Ssid[0] = '\0';
1016 } 1008 }
1009 memcpy(bssid->Ssid.Ssid, (p + 2), ssid_len);
1010 bssid->Ssid.SsidLength = ssid_len;
1017 1011
1018 RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s bssid.Ssid.Ssid:%s bssid.Ssid.SsidLength:%d " 1012 RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s bssid.Ssid.Ssid:%s bssid.Ssid.SsidLength:%d "
1019 "cur_network->network.Ssid.Ssid:%s len:%d\n", __func__, bssid->Ssid.Ssid, 1013 "cur_network->network.Ssid.Ssid:%s len:%d\n", __func__, bssid->Ssid.Ssid,