From 6b461f68c72e127777e2b4aa7511d0e6318d57e2 Mon Sep 17 00:00:00 2001 From: Xinyue Ling Date: Mon, 13 Jun 2022 14:29:56 +0800 Subject: [PATCH] Set current_ssid before changing state to ASSOCIATING For hidden GBK encoding of a Chinese SSID, both the UTF-8 and GBK encoding profiles are added into wpa_supplicant to make sure the connection succeeds. In this situation, wpa_supplicant_select_network() will not be called so current_ssid is NULL when association begins. Android monitors the WPA_EVENT_STATE_CHANGE event to get the SSID and BSSID. When connecting to a Chinese SSID, in case of association rejection happens, Android will report null SSID to OEM APP because current_ssid is updated after wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATING), which may cause confusion. Fix this by setting the current_ssid before changing state to ASSOCIATING. Signed-off-by: Jouni Malinen --- wpa_supplicant/wpa_supplicant.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index cf68417ca..c2ce2c934 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -3772,6 +3772,11 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit) wpa_supplicant_set_wpa_none_key(wpa_s, ssid); } + /* Set current_ssid before changing state to ASSOCIATING, so that the + * selected SSID is available to wpas_notify_state_changed(). */ + old_ssid = wpa_s->current_ssid; + wpa_s->current_ssid = ssid; + wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATING); if (bss) { params.ssid = bss->ssid; @@ -4007,7 +4012,7 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit) #endif /* CONFIG_P2P */ if (wpa_s->reassoc_same_ess && !is_zero_ether_addr(prev_bssid) && - wpa_s->current_ssid) + old_ssid) params.prev_bssid = prev_bssid; #ifdef CONFIG_SAE @@ -4075,15 +4080,13 @@ static void wpas_start_assoc_cb(struct wpa_radio_work *work, int deinit) } #endif /* CONFIG_WEP */ - if (wpa_s->current_ssid && wpa_s->current_ssid != ssid) { + if (old_ssid && old_ssid != ssid) { /* * Do not allow EAP session resumption between different * network configurations. */ eapol_sm_invalidate_cached_session(wpa_s->eapol); } - old_ssid = wpa_s->current_ssid; - wpa_s->current_ssid = ssid; if (!wpas_driver_bss_selection(wpa_s) || ssid->bssid_set) { wpa_s->current_bss = bss;