From patchwork Mon Dec 15 12:23:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Tomanek X-Patchwork-Id: 421151 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B0AAD1400D2 for ; Mon, 15 Dec 2014 23:23:52 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 9A09A17C035; Mon, 15 Dec 2014 07:23:48 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Jd12TZRJA+uW; Mon, 15 Dec 2014 07:23:48 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 281739D2A1; Mon, 15 Dec 2014 07:23:42 -0500 (EST) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id E42F69C206 for ; Mon, 15 Dec 2014 07:23:40 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0pi+YsWBoyYM for ; Mon, 15 Dec 2014 07:23:34 -0500 (EST) Received: from zirkel.wertarbyte.de (zirkel.wertarbyte.de [188.40.44.137]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id EFB7917C001 for ; Mon, 15 Dec 2014 07:23:32 -0500 (EST) Received: from stefan by zirkel.wertarbyte.de with local (Exim 4.72) (envelope-from ) id 1Y0UgV-0008IJ-SI for hostap@lists.shmoo.com; Mon, 15 Dec 2014 13:23:31 +0100 Date: Mon, 15 Dec 2014 13:23:31 +0100 From: Stefan Tomanek To: hostap@lists.shmoo.com Subject: [PATCH] Add ssids_equal() to compare SSIDs Message-ID: <20141215122331.GF15168@zirkel.wertarbyte.de> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: stefan.tomanek@wertarbyte.de X-SA-Exim-Scanned: No (on zirkel.wertarbyte.de); SAEximRunCond expanded to false X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com This change moves the common task of comparing both length values and the corresponding byte arrays into a generic function call taking both ssid pointers and lengths as arguments. Signed-off-by: Stefan Tomanek --- src/ap/beacon.c | 10 +++------- src/ap/hostapd.c | 3 +-- src/ap/wps_hostapd.c | 8 ++------ src/rsn_supp/preauth.c | 3 +-- src/utils/common.c | 11 +++++++++++ src/utils/common.h | 2 ++ wlantest/bss.c | 6 ++---- wpa_supplicant/bss.c | 13 ++++--------- wpa_supplicant/events.c | 4 +--- wpa_supplicant/interworking.c | 16 +++++----------- wpa_supplicant/p2p_supplicant.c | 25 ++++++++----------------- wpa_supplicant/sme.c | 3 +-- wpa_supplicant/wnm_sta.c | 3 +-- wpa_supplicant/wpa_supplicant.c | 9 +++------ wpa_supplicant/wpas_glue.c | 6 ++---- 15 files changed, 47 insertions(+), 75 deletions(-) diff --git a/src/ap/beacon.c b/src/ap/beacon.c index f73f83a..df031bf 100644 --- a/src/ap/beacon.c +++ b/src/ap/beacon.c @@ -487,8 +487,7 @@ static enum ssid_match_result ssid_match(struct hostapd_data *hapd, if (ssid_len == 0) wildcard = 1; - if (ssid_len == hapd->conf->ssid.ssid_len && - os_memcmp(ssid, hapd->conf->ssid.ssid, ssid_len) == 0) + if (ssids_equal(ssid, ssid_len, hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len)) return EXACT_SSID_MATCH; if (ssid_list == NULL) @@ -501,8 +500,7 @@ static enum ssid_match_result ssid_match(struct hostapd_data *hapd, break; if (pos[1] == 0) wildcard = 1; - if (pos[1] == hapd->conf->ssid.ssid_len && - os_memcmp(pos + 2, hapd->conf->ssid.ssid, pos[1]) == 0) + if (ssids_equal(pos + 2, pos[1], hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len)) return EXACT_SSID_MATCH; pos += 2 + pos[1]; } @@ -589,9 +587,7 @@ void handle_probe_req(struct hostapd_data *hapd, #ifdef CONFIG_P2P if ((hapd->conf->p2p & P2P_GROUP_OWNER) && - elems.ssid_len == P2P_WILDCARD_SSID_LEN && - os_memcmp(elems.ssid, P2P_WILDCARD_SSID, - P2P_WILDCARD_SSID_LEN) == 0) { + ssids_equal(elems.ssid, elems.ssid_len, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN)) { /* Process P2P Wildcard SSID like Wildcard SSID */ elems.ssid_len = 0; } diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 5161333..6472f26 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -785,8 +785,7 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first) * from what is being used then force installation of the * new SSID. */ - set_ssid = (conf->ssid.ssid_len != (size_t) ssid_len || - os_memcmp(conf->ssid.ssid, ssid, ssid_len) != 0); + set_ssid = !ssids_equal(ssid, ssid_len, conf->ssid.ssid, conf->ssid.ssid_len); } else { /* * No SSID in the config file; just use the one we got diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c index 9ba7aba..b844c67 100644 --- a/src/ap/wps_hostapd.c +++ b/src/ap/wps_hostapd.c @@ -1340,9 +1340,7 @@ static int hostapd_wps_probe_req_rx(void *ctx, const u8 *addr, const u8 *da, } if (elems.ssid && elems.ssid_len > 0 && - (elems.ssid_len != hapd->conf->ssid.ssid_len || - os_memcmp(elems.ssid, hapd->conf->ssid.ssid, elems.ssid_len) != - 0)) + !ssids_equal(elems.ssid, elems.ssid_len, hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len)) return 0; /* Not for us */ wps_ie = ieee802_11_vendor_ie_concat(ie, ie_len, WPS_DEV_OUI_WFA); @@ -1356,9 +1354,7 @@ static int hostapd_wps_probe_req_rx(void *ctx, const u8 *addr, const u8 *da, if (wpabuf_len(wps_ie) > 0) { int p2p_wildcard = 0; #ifdef CONFIG_P2P - if (elems.ssid && elems.ssid_len == P2P_WILDCARD_SSID_LEN && - os_memcmp(elems.ssid, P2P_WILDCARD_SSID, - P2P_WILDCARD_SSID_LEN) == 0) + if (elems.ssid && ssids_equal(elems.ssid, elems.ssid_len, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN)) p2p_wildcard = 1; #endif /* CONFIG_P2P */ wps_registrar_probe_req_rx(hapd->wps->registrar, addr, wps_ie, diff --git a/src/rsn_supp/preauth.c b/src/rsn_supp/preauth.c index af0e108..bb0d6e1 100644 --- a/src/rsn_supp/preauth.c +++ b/src/rsn_supp/preauth.c @@ -458,8 +458,7 @@ void rsn_preauth_scan_result(struct wpa_sm *sm, const u8 *bssid, struct wpa_ie_data ie; struct rsn_pmksa_cache_entry *pmksa; - if (ssid[1] != sm->ssid_len || - os_memcmp(ssid + 2, sm->ssid, sm->ssid_len) != 0) + if (!ssids_equal(ssid + 2, ssid[1], sm->ssid, sm->ssid_len)) return; /* Not for the current SSID */ if (os_memcmp(bssid, sm->bssid, ETH_ALEN) == 0) diff --git a/src/utils/common.c b/src/utils/common.c index 422b476..83aecdf 100644 --- a/src/utils/common.c +++ b/src/utils/common.c @@ -531,6 +531,17 @@ const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len) return ssid_txt; } +/** + * ssids_equal - Check two SSID values for equality + * @ssid_a: first SSID (32-octet string) + * @len_a: Length of first SSID in octets + * @ssid_b: second SSID (32-octet string) + * @len_b: Length of second SSID in octets + * Returns: 1 on equality, 0 otherwise + */ +int ssids_equal(const u8 *ssid_a, size_t len_a, const u8 *ssid_b, size_t len_b) { + return (len_a == len_b) && (os_memcmp(ssid_a, ssid_b, len_a) == 0); +} void * __hide_aliasing_typecast(void *foo) { diff --git a/src/utils/common.h b/src/utils/common.h index 70d76a9..ed89d2a 100644 --- a/src/utils/common.h +++ b/src/utils/common.h @@ -495,6 +495,8 @@ size_t printf_decode(u8 *buf, size_t maxlen, const char *str); const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len); +int ssids_equal(const u8 *ssid_a, size_t len_a, const u8 *ssid_b, size_t len_b); + char * wpa_config_parse_string(const char *value, size_t *len); int is_hex(const u8 *data, size_t len); int find_first_bit(u32 value); diff --git a/wlantest/bss.c b/wlantest/bss.c index 0f773bf..b8adc25 100644 --- a/wlantest/bss.c +++ b/wlantest/bss.c @@ -118,8 +118,7 @@ static void bss_add_pmk(struct wlantest *wt, struct wlantest_bss *bss) os_memcmp(p->bssid, bss->bssid, ETH_ALEN) != 0) continue; if (p->ssid_len && - (p->ssid_len != bss->ssid_len || - os_memcmp(p->ssid, bss->ssid, p->ssid_len) != 0)) + !ssids_equal(p->ssid, p->ssid_len, bss->ssid, bss->ssid_len)) continue; if (bss_add_pmk_from_passphrase(bss, p->passphrase) < 0) @@ -144,8 +143,7 @@ void bss_update(struct wlantest *wt, struct wlantest_bss *bss, return; } - if (bss->ssid_len != elems->ssid_len || - os_memcmp(bss->ssid, elems->ssid, bss->ssid_len) != 0) { + if (!ssids_equal(elems->ssid, elems->ssid_len, bss->ssid, bss->ssid_len)) { wpa_printf(MSG_DEBUG, "Store SSID '%s' for BSSID " MACSTR, wpa_ssid_txt(elems->ssid, elems->ssid_len), MAC2STR(bss->bssid)); diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c index 1798439..d11cd26 100644 --- a/wpa_supplicant/bss.c +++ b/wpa_supplicant/bss.c @@ -244,8 +244,7 @@ struct wpa_bss * wpa_bss_get(struct wpa_supplicant *wpa_s, const u8 *bssid, return NULL; dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { if (os_memcmp(bss->bssid, bssid, ETH_ALEN) == 0 && - bss->ssid_len == ssid_len && - os_memcmp(bss->ssid, ssid, ssid_len) == 0) + ssids_equal(ssid, ssid_len, bss->ssid, bss->ssid_len)) return bss; } return NULL; @@ -294,8 +293,7 @@ static int wpa_bss_known(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { if (ssid->ssid == NULL || ssid->ssid_len == 0) continue; - if (ssid->ssid_len == bss->ssid_len && - os_memcmp(ssid->ssid, bss->ssid, ssid->ssid_len) == 0) + if (ssids_equal(ssid->ssid, ssid->ssid_len, bss->ssid, bss->ssid_len)) return 1; } @@ -665,8 +663,7 @@ void wpa_bss_update_scan_res(struct wpa_supplicant *wpa_s, return; } #endif /* CONFIG_P2P */ - if (p2p && ssid[1] == P2P_WILDCARD_SSID_LEN && - os_memcmp(ssid + 2, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN) == 0) + if (p2p && ssids_equal(ssid + 2, ssid[1], (const u8 *)P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN)) return; /* Skip P2P listen discovery results here */ /* TODO: add option for ignoring BSSes we are not interested in @@ -740,9 +737,7 @@ static int wpa_bss_included_in_scan(const struct wpa_bss *bss, for (i = 0; i < info->num_ssids; i++) { const struct wpa_driver_scan_ssid *s = &info->ssids[i]; if ((s->ssid == NULL || s->ssid_len == 0) || - (s->ssid_len == bss->ssid_len && - os_memcmp(s->ssid, bss->ssid, bss->ssid_len) == - 0)) { + ssids_equal(s->ssid, s->ssid_len, bss->ssid, bss->ssid_len)) { found = 1; break; } diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 5ef64e6..c504954 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -817,9 +817,7 @@ static struct wpa_ssid * wpa_scan_res_match(struct wpa_supplicant *wpa_s, os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) == 0) check_ssid = 0; - if (check_ssid && - (bss->ssid_len != ssid->ssid_len || - os_memcmp(bss->ssid, ssid->ssid, bss->ssid_len) != 0)) { + if (check_ssid && ssids_equal(ssid->ssid, ssid->ssid_len, bss->ssid, bss->ssid_len)) { wpa_dbg(wpa_s, MSG_DEBUG, " skip - SSID mismatch"); continue; } diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c index 8c4ea34..e67eb1d 100644 --- a/wpa_supplicant/interworking.c +++ b/wpa_supplicant/interworking.c @@ -832,8 +832,7 @@ static int already_connected(struct wpa_supplicant *wpa_s, if (ssid->parent_cred != cred) return 0; - if (ssid->ssid_len != bss->ssid_len || - os_memcmp(ssid->ssid, bss->ssid, bss->ssid_len) != 0) + if (!ssids_equal(ssid->ssid, ssid->ssid_len, bss->ssid, bss->ssid_len)) return 0; sel_ssid = NULL; @@ -854,8 +853,7 @@ static void remove_duplicate_network(struct wpa_supplicant *wpa_s, for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { if (ssid->parent_cred != cred) continue; - if (ssid->ssid_len != bss->ssid_len || - os_memcmp(ssid->ssid, bss->ssid, bss->ssid_len) != 0) + if (!ssids_equal(ssid->ssid, ssid->ssid_len, bss->ssid, bss->ssid_len)) continue; break; @@ -1121,8 +1119,7 @@ static int cred_excluded_ssid(struct wpa_cred *cred, struct wpa_bss *bss) for (i = 0; i < cred->num_excluded_ssid; i++) { struct excluded_ssid *e = &cred->excluded_ssid[i]; - if (bss->ssid_len == e->ssid_len && - os_memcmp(bss->ssid, e->ssid, e->ssid_len) == 0) + if (ssids_equal(e->ssid, e->ssid_len, bss->ssid, bss->ssid_len)) return 1; } @@ -2165,9 +2162,7 @@ static int interworking_find_network_match(struct wpa_supplicant *wpa_s) if (wpas_network_disabled(wpa_s, ssid) || ssid->mode != WPAS_MODE_INFRA) continue; - if (ssid->ssid_len != bss->ssid_len || - os_memcmp(ssid->ssid, bss->ssid, ssid->ssid_len) != - 0) + if (!ssids_equal(ssid->ssid, ssid->ssid_len, bss->ssid, bss->ssid_len)) continue; /* * TODO: Consider more accurate matching of security @@ -2459,8 +2454,7 @@ interworking_match_anqp_info(struct wpa_supplicant *wpa_s, struct wpa_bss *bss) continue; if (os_memcmp(bss->hessid, other->hessid, ETH_ALEN) != 0) continue; - if (bss->ssid_len != other->ssid_len || - os_memcmp(bss->ssid, other->ssid, bss->ssid_len) != 0) + if (!ssids_equal(other->ssid, other->ssid_len, bss->ssid, bss->ssid_len)) continue; wpa_printf(MSG_DEBUG, "Interworking: Share ANQP data with " diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index 267b59b..501e661 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -428,8 +428,7 @@ static struct wpa_supplicant * wpas_get_p2p_group(struct wpa_supplicant *wpa_s, for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) { for (s = wpa_s->conf->ssid; s; s = s->next) { if (s->disabled != 0 || !s->p2p_group || - s->ssid_len != ssid_len || - os_memcmp(ssid, s->ssid, ssid_len) != 0) + !ssids_equal(ssid, ssid_len, s->ssid, s->ssid_len)) continue; if (s->mode == WPAS_MODE_P2P_GO && s != wpa_s->current_ssid) @@ -734,8 +733,7 @@ static int wpas_p2p_store_persistent_group(struct wpa_supplicant *wpa_s, for (s = wpa_s->conf->ssid; s; s = s->next) { if (s->disabled == 2 && os_memcmp(go_dev_addr, s->bssid, ETH_ALEN) == 0 && - s->ssid_len == ssid->ssid_len && - os_memcmp(ssid->ssid, s->ssid, ssid->ssid_len) == 0) + ssids_equal(ssid->ssid, ssid->ssid_len, s->ssid, s->ssid_len)) break; } @@ -828,8 +826,7 @@ static void wpas_p2p_add_persistent_group_client(struct wpa_supplicant *wpa_s, if (s->disabled != 2 || s->mode != WPAS_MODE_P2P_GO) continue; - if (s->ssid_len == ssid->ssid_len && - os_memcmp(s->ssid, ssid->ssid, s->ssid_len) == 0) + if (ssids_equal(s->ssid, s->ssid_len, ssid->ssid, ssid->ssid_len)) break; } @@ -2960,9 +2957,7 @@ static void wpas_prov_disc_req(void *ctx, const u8 *peer, u16 config_methods, struct wpa_ssid *s = group->current_ssid; if (s != NULL && s->mode == WPAS_MODE_P2P_GO && - group_id_len - ETH_ALEN == s->ssid_len && - os_memcmp(group_id + ETH_ALEN, s->ssid, - s->ssid_len) == 0) + ssids_equal(group_id + ETH_ALEN, group_id_len - ETH_ALEN, s->ssid, s->ssid_len)) break; } } @@ -3188,8 +3183,7 @@ static u8 wpas_invitation_process(void *ctx, const u8 *sa, const u8 *bssid, for (s = wpa_s->conf->ssid; s; s = s->next) { if (s->disabled == 2 && os_memcmp(s->bssid, go_dev_addr, ETH_ALEN) == 0 && - s->ssid_len == ssid_len && - os_memcmp(ssid, s->ssid, ssid_len) == 0) + ssids_equal(ssid, ssid_len, s->ssid, ssid_len)) break; } @@ -3279,8 +3273,7 @@ static void wpas_invitation_received(void *ctx, const u8 *sa, const u8 *bssid, for (s = wpa_s->conf->ssid; s; s = s->next) { if (s->disabled == 2 && - s->ssid_len == ssid_len && - os_memcmp(ssid, s->ssid, ssid_len) == 0) + ssids_equal(ssid, ssid_len, s->ssid, s->ssid_len)) break; } @@ -3862,8 +3855,7 @@ struct wpa_supplicant * wpas_get_p2p_go_iface(struct wpa_supplicant *wpa_s, s->mode != WPAS_MODE_AP && s->mode != WPAS_MODE_P2P_GROUP_FORMATION) continue; - if (s->ssid_len != ssid_len || - os_memcmp(ssid, s->ssid, ssid_len) != 0) + if (ssids_equal(ssid, ssid_len, s->ssid,s->ssid_len)) continue; return wpa_s; } @@ -7034,8 +7026,7 @@ struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s, if (s->disabled != 2) continue; if (ssid && - (ssid_len != s->ssid_len || - os_memcmp(ssid, s->ssid, ssid_len) != 0)) + !ssids_equal(ssid, ssid_len, s->ssid, s->ssid_len)) continue; if (addr == NULL) { if (s->mode == WPAS_MODE_P2P_GO) diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index 7eb8966..bb59a97 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -226,8 +226,7 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s, params.ssid_len = bss->ssid_len; params.p2p = ssid->p2p_group; - if (wpa_s->sme.ssid_len != params.ssid_len || - os_memcmp(wpa_s->sme.ssid, params.ssid, params.ssid_len) != 0) + if (!ssids_equal(params.ssid, params.ssid_len, wpa_s->sme.ssid, wpa_s->sme.ssid_len)) wpa_s->sme.prev_bssid_set = 0; wpa_s->sme.freq = params.freq; diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 954de67..2dc4661 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -501,8 +501,7 @@ compare_scan_neighbor_results(struct wpa_supplicant *wpa_s) continue; } - if (bss->ssid_len != target->ssid_len || - os_memcmp(bss->ssid, target->ssid, bss->ssid_len) != 0) { + if (!ssids_equal(target->ssid, target->ssid_len, bss->ssid, bss->ssid_len)) { /* * TODO: Could consider allowing transition to another * ESS if PMF was enabled for the association. diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 68fcbef..24c44a2 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -2596,8 +2596,7 @@ struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s) entry = wpa_s->conf->ssid; while (entry) { if (!wpas_network_disabled(wpa_s, entry) && - ((ssid_len == entry->ssid_len && - os_memcmp(ssid, entry->ssid, ssid_len) == 0) || wired) && + (ssids_equal(ssid, ssid_len, entry->ssid, entry->ssid_len) || wired) && (!entry->bssid_set || os_memcmp(bssid, entry->bssid, ETH_ALEN) == 0)) return entry; @@ -4443,8 +4442,7 @@ static int * get_bss_freqs_in_ess(struct wpa_supplicant *wpa_s) dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { if (bss == cbss) continue; - if (bss->ssid_len == cbss->ssid_len && - os_memcmp(bss->ssid, cbss->ssid, bss->ssid_len) == 0 && + if (ssids_equal(bss->ssid, bss->ssid_len, cbss->ssid, cbss->ssid_len) && wpa_blacklist_get(wpa_s, bss->bssid) == NULL) { add_freq(freqs, &num_freqs, bss->freq); if (num_freqs == max_freqs) @@ -4795,8 +4793,7 @@ int disallowed_ssid(struct wpa_supplicant *wpa_s, const u8 *ssid, for (i = 0; i < wpa_s->disallow_aps_ssid_count; i++) { struct wpa_ssid_value *s = &wpa_s->disallow_aps_ssid[i]; - if (ssid_len == s->ssid_len && - os_memcmp(ssid, s->ssid, ssid_len) == 0) + if (ssids_equal(ssid, ssid_len, s->ssid, s->ssid_len)) return 1; } diff --git a/wpa_supplicant/wpas_glue.c b/wpa_supplicant/wpas_glue.c index 3bf5135..3a02cb6 100644 --- a/wpa_supplicant/wpas_glue.c +++ b/wpa_supplicant/wpas_glue.c @@ -376,10 +376,8 @@ static int wpa_get_beacon_ie(struct wpa_supplicant *wpa_s) dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { if (os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) != 0) continue; - if (ssid == NULL || - ((bss->ssid_len == ssid->ssid_len && - os_memcmp(bss->ssid, ssid->ssid, ssid->ssid_len) == 0) || - ssid->ssid_len == 0)) { + if (ssid == NULL || ssid->ssid_len == 0 || + ssids_equal(bss->ssid, bss->ssid_len, ssid->ssid, ssid->ssid_len)) { curr = bss; break; }