From c1c023429b8e839bfb6505c224ae74fd3f1ae7ad Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 25 Jun 2012 14:23:25 +0300 Subject: [PATCH] Set state to DISCONNECTED on auth/assoc failures Some of the authentication/association failure paths left wpa_state to its previous value. This can result in unexpected behavior when wpa_supplicant tries to find an AP to connect to since the uncleared state can result the in the selected BSS being ignored if it is same as the previously used BSS. This could happen, e.g., when wpa_supplicant SME was used and the AP rejected authentication. Fix this by explicitly setting state to DISCONNECTED on auth/assoc failures that did not yet do this. Signed-hostap: Jouni Malinen intended-for: hostap-1 --- wpa_supplicant/sme.c | 2 ++ wpa_supplicant/wpa_supplicant.c | 1 + 2 files changed, 3 insertions(+) diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index 1586a5af5..c7187e43d 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -332,6 +332,7 @@ void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data) wpa_s->sme.auth_alg == data->auth.auth_type || wpa_s->current_ssid->auth_alg == WPA_AUTH_ALG_LEAP) { wpas_connection_failed(wpa_s, wpa_s->pending_bssid); + wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED); return; } @@ -448,6 +449,7 @@ void sme_associate(struct wpa_supplicant *wpa_s, enum wpas_mode mode, wpa_msg(wpa_s, MSG_INFO, "SME: Association request to the " "driver failed"); wpas_connection_failed(wpa_s, wpa_s->pending_bssid); + wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED); os_memset(wpa_s->pending_bssid, 0, ETH_ALEN); return; } diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 803a51291..fa1423921 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -1440,6 +1440,7 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, * succeed. */ wpas_connection_failed(wpa_s, wpa_s->pending_bssid); + wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED); os_memset(wpa_s->pending_bssid, 0, ETH_ALEN); return; }