From af670cb418dc836ef96cee88027144777a1f3e6f Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 3 Jan 2020 18:06:01 +0200 Subject: [PATCH] SME: Postpone current BSSID clearing until IEs are prepared sme_send_authentication() could fail before actually requesting the driver to authenticate with a new AP. This could happen after wpa_s->bssid got cleared even though in such a case, the old association is maintained and still valid. This can result in unexpected behavior since wpa_s->bssid would not match the current BSSID anymore. Fix this by postponing clearing of wpa_s->bssid until the IE preparation has been completed successfully. Signed-off-by: Jouni Malinen --- wpa_supplicant/sme.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index 08d7e3ece..2d7373e55 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -372,12 +372,6 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s, } params.wep_tx_keyidx = ssid->wep_tx_keyidx; - bssid_changed = !is_zero_ether_addr(wpa_s->bssid); - os_memset(wpa_s->bssid, 0, ETH_ALEN); - os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN); - if (bssid_changed) - wpas_notify_bssid_changed(wpa_s); - if ((wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE) || wpa_bss_get_ie(bss, WLAN_EID_RSN)) && wpa_key_mgmt_wpa(ssid->key_mgmt)) { @@ -718,6 +712,12 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s, } #endif /* CONFIG_SAE */ + bssid_changed = !is_zero_ether_addr(wpa_s->bssid); + os_memset(wpa_s->bssid, 0, ETH_ALEN); + os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN); + if (bssid_changed) + wpas_notify_bssid_changed(wpa_s); + old_ssid = wpa_s->current_ssid; wpa_s->current_ssid = ssid; wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);