nl80211: Filter out unsupported bands

If the driver indicates capability for a band that
hostapd/wpa_supplicant does not support, the struct hostapd_hw_modes
array of bands got an empty entry for that with NUM_HOSTAPD_MODES as the
mode. This resulted in various issues, e.g., with fst_hw_mode_to_band()
hitting a WPA_ASSERT(0).

Fix this by filtering out unsupported bands from the internal data
structures.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2020-10-26 22:34:07 +02:00 committed by Jouni Malinen
parent 9c39c1a6d3
commit 106d67a93c

View file

@ -1963,6 +1963,22 @@ wpa_driver_nl80211_postprocess_modes(struct hostapd_hw_modes *modes,
modes[m].mode = HOSTAPD_MODE_IEEE80211A; modes[m].mode = HOSTAPD_MODE_IEEE80211A;
} }
/* Remove unsupported bands */
m = 0;
while (m < *num_modes) {
if (modes[m].mode == NUM_HOSTAPD_MODES) {
wpa_printf(MSG_DEBUG,
"nl80211: Remove unsupported mode");
os_free(modes[m].channels);
os_free(modes[m].rates);
os_memmove(&modes[m], &modes[m + 1],
sizeof(struct hostapd_hw_modes));
(*num_modes)--;
continue;
}
m++;
}
/* If only 802.11g mode is included, use it to construct matching /* If only 802.11g mode is included, use it to construct matching
* 802.11b mode data. */ * 802.11b mode data. */