]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Set current_ssid before changing state to ASSOCIATING
authorXinyue Ling <quic_xinyling@quicinc.com>
Mon, 13 Jun 2022 06:29:56 +0000 (14:29 +0800)
committerJouni Malinen <j@w1.fi>
Thu, 16 Jun 2022 15:02:07 +0000 (18:02 +0300)
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 <quic_jouni@quicinc.com>
wpa_supplicant/wpa_supplicant.c

index cf68417caa108beca2fdc2e3e5fb4b8b8a86a4b6..c2ce2c9340c91b03ee67b30f9cbf4508f7022c17 100644 (file)
@@ -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;