From 03b2f53f766c7e77565843a152af9f720cbe3d07 Mon Sep 17 00:00:00 2001 From: Shreyas Sheth Date: Mon, 14 Oct 2024 14:52:24 +0530 Subject: [PATCH] fix(wifi): Resolve comments for softap fixes --- .../wpa_supplicant/esp_supplicant/src/esp_hostap.c | 2 +- .../wpa_supplicant/esp_supplicant/src/esp_wpa3.c | 9 +++++---- components/wpa_supplicant/src/ap/sta_info.c | 8 ++++---- components/wpa_supplicant/src/ap/wpa_auth_ie.c | 11 +++++++++++ components/wpa_supplicant/src/common/wpa_common.c | 3 +++ components/wpa_supplicant/src/rsn_supp/wpa_ie.c | 4 ++++ 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c b/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c index c6758e4708..813a96a288 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_hostap.c @@ -358,7 +358,7 @@ uint8_t wpa_status_to_reason_code(int status) } bool hostap_new_assoc_sta(struct sta_info *sta, uint8_t *bssid, uint8_t *wpa_ie, - uint8_t wpa_ie_len, uint8_t *rsnxe, uint8_t rsnxe_len, + uint8_t wpa_ie_len, uint8_t *rsnxe, uint16_t rsnxe_len, bool *pmf_enable, int subtype, uint8_t *pairwise_cipher, uint8_t *reason) { struct hostapd_data *hapd = (struct hostapd_data*)esp_wifi_get_hostap_private_internal(); diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wpa3.c b/components/wpa_supplicant/esp_supplicant/src/esp_wpa3.c index 600ffd8c35..aa858144b3 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wpa3.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wpa3.c @@ -539,14 +539,15 @@ static void wpa3_process_rx_confirm(wpa3_hostap_auth_event_t *evt) esp_wifi_ap_get_sta_aid(frm->bssid, &aid); if (aid == 0) { esp_wifi_ap_deauth_internal(frm->bssid, ret); + } else { + if (sta && sta->sae_data) { + wpabuf_free(sta->sae_data); + sta->sae_data = NULL; + } } } } done: - if (sta && sta->sae_data) { - wpabuf_free(sta->sae_data); - sta->sae_data = NULL; - } os_free(frm); } diff --git a/components/wpa_supplicant/src/ap/sta_info.c b/components/wpa_supplicant/src/ap/sta_info.c index 435843cef6..0894486373 100644 --- a/components/wpa_supplicant/src/ap/sta_info.c +++ b/components/wpa_supplicant/src/ap/sta_info.c @@ -113,10 +113,10 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta) os_mutex_delete(sta->lock); sta->lock = NULL; } - if (sta->sae_data) { - wpabuf_free(sta->sae_data); - sta->sae_data = NULL; - } + if (sta->sae_data) { + wpabuf_free(sta->sae_data); + sta->sae_data = NULL; + } #endif /* CONFIG_SAE */ wpa_auth_sta_deinit(sta->wpa_sm); #ifdef CONFIG_WPS_REGISTRAR diff --git a/components/wpa_supplicant/src/ap/wpa_auth_ie.c b/components/wpa_supplicant/src/ap/wpa_auth_ie.c index eb57f021bb..1eedb701c2 100644 --- a/components/wpa_supplicant/src/ap/wpa_auth_ie.c +++ b/components/wpa_supplicant/src/ap/wpa_auth_ie.c @@ -572,6 +572,17 @@ wpa_validate_wpa_ie(struct wpa_authenticator *wpa_auth, } } +#ifdef CONFIG_SAE + if (wpa_auth->conf.ieee80211w == MGMT_FRAME_PROTECTION_OPTIONAL && + wpa_auth->conf.sae_require_mfp && + wpa_key_mgmt_sae(sm->wpa_key_mgmt) && + !(data.capabilities & WPA_CAPABILITY_MFPC)) { + wpa_printf(MSG_DEBUG, + "Management frame protection required with SAE, but client did not enable it"); + return WPA_MGMT_FRAME_PROTECTION_VIOLATION; + } +#endif /* CONFIG_SAE */ + if (wpa_auth->conf.ieee80211w == NO_MGMT_FRAME_PROTECTION || !(data.capabilities & WPA_CAPABILITY_MFPC)) sm->mgmt_frame_prot = 0; diff --git a/components/wpa_supplicant/src/common/wpa_common.c b/components/wpa_supplicant/src/common/wpa_common.c index 3574a21666..137187b83c 100644 --- a/components/wpa_supplicant/src/common/wpa_common.c +++ b/components/wpa_supplicant/src/common/wpa_common.c @@ -5,6 +5,7 @@ * This software may be distributed under the terms of the BSD license. * See README for more details. */ + #ifdef ESP_SUPPLICANT #include "utils/includes.h" #include "utils/common.h" @@ -1541,3 +1542,5 @@ int wpa_cipher_put_suites(u8 *pos, int ciphers) return num_suites; } + +#endif // ESP_SUPPLICANT diff --git a/components/wpa_supplicant/src/rsn_supp/wpa_ie.c b/components/wpa_supplicant/src/rsn_supp/wpa_ie.c index 22d052dd6d..34969aee6c 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa_ie.c +++ b/components/wpa_supplicant/src/rsn_supp/wpa_ie.c @@ -11,6 +11,7 @@ * * See README and COPYING for more details. */ + #ifdef ESP_SUPPLICANT #include "utils/includes.h" @@ -451,3 +452,6 @@ int wpa_supplicant_parse_ies(const u8 *buf, size_t len, return ret; } + + +#endif // ESP_SUPPLICANT