Skip to content

Commit 4ad74c0

Browse files
committed
Check SSID length first
Check the lengths of the two SSIDs first before using 'memcmp'. Otherwise, unexpected results might occur. (In C99 standard : "The 'memcmp' function compares the first n characters of the object pointed to by s1 to the first n characters of the object pointed to by s2.")
1 parent dd2bcec commit 4ad74c0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

vwifi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,8 @@ static int vwifi_join_ibss(struct wiphy *wiphy,
20862086
memcpy(vif->bssid, ndev->dev_addr, ETH_ALEN);
20872087
struct vwifi_vif *ibss_vif = NULL;
20882088
list_for_each_entry (ibss_vif, &vwifi->ibss_list, ibss_list) {
2089-
if (!memcmp(ibss_vif->ssid, vif->ssid, vif->ssid_len) &&
2089+
if (ibss_vif->ssid_len == vif->ssid_len &&
2090+
!memcmp(ibss_vif->ssid, vif->ssid, vif->ssid_len) &&
20902091
ibss_vif->ibss_chandef.center_freq1 ==
20912092
vif->ibss_chandef.center_freq1) {
20922093
memcpy(vif->bssid, ibss_vif->bssid, ETH_ALEN);

0 commit comments

Comments
 (0)