]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Fix frequencies array boundary check for scanned frequencies
authorAvraham Stern <avraham.stern@intel.com>
Tue, 28 Feb 2023 11:10:01 +0000 (13:10 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 1 Mar 2023 08:36:04 +0000 (10:36 +0200)
The number of frequencies is increased before the boundary check,
thus it should be allowed to be equal to the number of elements in
the array. Update the limit to allow the full array to be used.

In addition, add the missing byte for the NULL terminator for the debug
print to be able to fit all values (assuming they are <= 9999 MHz).

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
src/drivers/driver_nl80211_event.c

index e3fcb440226777e96ccaadee9102c93fc0a7c034..3a2faf63e5aab567f5fcb81cd2cd1382dd5b1bce 100644 (file)
@@ -1717,7 +1717,7 @@ static void send_scan_event(struct wpa_driver_nl80211_data *drv, int aborted,
                }
        }
        if (tb[NL80211_ATTR_SCAN_FREQUENCIES]) {
-               char msg[MAX_REPORT_FREQS * 5], *pos, *end;
+               char msg[MAX_REPORT_FREQS * 5 + 1], *pos, *end;
                int res;
 
                pos = msg;
@@ -1732,7 +1732,7 @@ static void send_scan_event(struct wpa_driver_nl80211_data *drv, int aborted,
                        if (!os_snprintf_error(end - pos, res))
                                pos += res;
                        num_freqs++;
-                       if (num_freqs == MAX_REPORT_FREQS - 1)
+                       if (num_freqs == MAX_REPORT_FREQS)
                                break;
                }
                info->freqs = freqs;