]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Fix filtering of unsupported bands/modes
authorJouni Malinen <jouni@codeaurora.org>
Mon, 2 Nov 2020 16:38:41 +0000 (18:38 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 2 Nov 2020 16:38:41 +0000 (18:38 +0200)
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>
src/drivers/driver_nl80211_capa.c

index 227f665c7a3c50f9a0fea4dfa93d984b5cf01698..287b8aa30e63c258741ea637436d4be591bf2375 100644 (file)
@@ -1971,8 +1971,10 @@ wpa_driver_nl80211_postprocess_modes(struct hostapd_hw_modes *modes,
                                   "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;
                }