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: 106d67a93c2d ("nl80211: Filter out unsupported bands")
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
"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));
+ if (m + 1 < *num_modes)
+ os_memmove(&modes[m], &modes[m + 1],
+ sizeof(struct hostapd_hw_modes) *
+ (*num_modes - (m + 1)));
(*num_modes)--;
continue;
}