From 8fd6985214fd9cf8f2b24c3d2fe1540bd5fe36bb Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 3 Feb 2021 11:47:01 -0600 Subject: [PATCH] station: move filtering of non-utf8 scan_bss entries Instead of silently ignoring entries with non-utf8 SSIDs, drop them from the new_bss_list entirely. --- src/station.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/station.c b/src/station.c index 8ff8bee1..ab2ba66e 100644 --- a/src/station.c +++ b/src/station.c @@ -330,11 +330,6 @@ static struct network *station_add_seen_bss(struct station *station, return NULL; } - if (!util_ssid_is_utf8(bss->ssid_len, bss->ssid)) { - l_debug("Ignoring BSS with non-UTF8 SSID"); - return NULL; - } - memcpy(ssid, bss->ssid, bss->ssid_len); ssid[bss->ssid_len] = '\0'; @@ -614,6 +609,22 @@ static bool station_start_anqp(struct station *station, struct network *network, return true; } +static bool bss_free_if_ssid_not_utf8(void *data, void *user_data) +{ + struct scan_bss *bss = data; + + if (util_ssid_is_hidden(bss->ssid_len, bss->ssid)) + return false; + + if (util_ssid_is_utf8(bss->ssid_len, bss->ssid)) + return false; + + l_debug("Dropping scan_bss '%s', with non-utf8 SSID", + util_address_to_string(bss->addr)); + bss_free(bss); + return true; +} + /* * Used when scan results were obtained; either from scan running * inside station module or scans running in other state machines, e.g. wsc @@ -627,6 +638,8 @@ void station_set_scan_results(struct station *station, struct network *network; bool wait_for_anqp = false; + l_queue_foreach_remove(new_bss_list, bss_free_if_ssid_not_utf8, NULL); + while ((network = l_queue_pop_head(station->networks_sorted))) network_bss_list_clear(network);