nl80211: Fix filtering of unsupported bands/modes

The loop for removing unsupported bands was assuming there is always
exactly one band/mode following the removed band. That was not at all
correct, so fix this by dynamically determining how many (if any) bands
need to be moved.

Fixes: 106d67a93c ("nl80211: Filter out unsupported bands")
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2020-11-02 18:38:41 +02:00 committed by Jouni Malinen
parent 3b89dbaa7d
commit c643c39287

View file

@ -1971,8 +1971,10 @@ wpa_driver_nl80211_postprocess_modes(struct hostapd_hw_modes *modes,
"nl80211: Remove unsupported mode"); "nl80211: Remove unsupported mode");
os_free(modes[m].channels); os_free(modes[m].channels);
os_free(modes[m].rates); os_free(modes[m].rates);
os_memmove(&modes[m], &modes[m + 1], if (m + 1 < *num_modes)
sizeof(struct hostapd_hw_modes)); os_memmove(&modes[m], &modes[m + 1],
sizeof(struct hostapd_hw_modes) *
(*num_modes - (m + 1)));
(*num_modes)--; (*num_modes)--;
continue; continue;
} }