mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +03:00
fix(wifi) : Fixed some issues found using static analysis
This commit is contained in:
@@ -393,6 +393,7 @@ u16 esp_send_assoc_resp(struct hostapd_data *hapd, const u8 *addr,
|
||||
struct wpabuf *owe_ie = esp_owe_build_assoc_resp_dhie(hapd, addr, &owe_ie_len);
|
||||
if (owe_ie_len <= 0 || !owe_ie) {
|
||||
wpa_printf(MSG_ERROR, "%s : error creating dhie for assoc resp %d ", __func__, owe_ie_len);
|
||||
wpabuf_free(owe_ie);
|
||||
return WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||
}
|
||||
esp_wifi_set_appie_internal(WIFI_APPIE_ASSOC_RESP, (uint8_t *)wpabuf_head(owe_ie), owe_ie_len, 0);
|
||||
@@ -497,11 +498,13 @@ bool hostap_new_assoc_sta(struct sta_info *sta, uint8_t *bssid, u8 *wpa_ie,
|
||||
|
||||
#ifdef CONFIG_OWE_SOFTAP
|
||||
uint8_t owe_enabled = esp_wifi_ap_get_owe_config_internal();
|
||||
if (hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_OWE &&
|
||||
if (status == WLAN_STATUS_SUCCESS &&
|
||||
hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_OWE &&
|
||||
sta->wpa_sm->wpa_key_mgmt == WPA_KEY_MGMT_OWE &&
|
||||
owe_dh && owe_enabled) {
|
||||
status = owe_process_assoc_req(hapd, sta, owe_dh, owe_ie_len);
|
||||
if (status != WLAN_STATUS_SUCCESS) {
|
||||
*reason = wpa_status_to_reason_code(status);
|
||||
wpa_printf(MSG_ERROR, "OWE : Failed to process assoc req status %d", status);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#ifdef CONFIG_OWE_SOFTAP
|
||||
#include "crypto/crypto.h"
|
||||
#include "ap/wpa_auth_i.h"
|
||||
#include "esp_owe_i.h"
|
||||
#define OWE_DH_GRP19 19
|
||||
#endif
|
||||
|
||||
@@ -817,8 +818,8 @@ uint16_t owe_process_assoc_req(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
return WLAN_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (!owe_dh) {
|
||||
wpa_printf(MSG_ERROR, "OWE: Invalid DH data received");
|
||||
if (!owe_dh || owe_dh_len < OWE_DHIE_LEN - 2) {
|
||||
wpa_printf(MSG_ERROR, "OWE: Invalid DH data received (len=%u)", owe_dh_len);
|
||||
return WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||
}
|
||||
|
||||
@@ -930,7 +931,13 @@ uint16_t owe_process_assoc_req(struct hostapd_data *hapd, struct sta_info *sta,
|
||||
sta->owe_pmk_len = SHA256_MAC_LEN;
|
||||
|
||||
// Add the PMK to the PMKSA cache
|
||||
wpa_auth_pmksa_add2(hapd->wpa_auth, sta->addr, sta->owe_pmk, sta->owe_pmk_len, pmkid, 0, WPA_KEY_MGMT_OWE, NULL);
|
||||
if (wpa_auth_pmksa_add2(hapd->wpa_auth, sta->addr, sta->owe_pmk, sta->owe_pmk_len,
|
||||
pmkid, 0, WPA_KEY_MGMT_OWE, NULL) < 0) {
|
||||
os_free(sta->owe_pmk);
|
||||
sta->owe_pmk = NULL;
|
||||
wpa_printf(MSG_ERROR, "OWE: Failed to add PMKSA cache entry");
|
||||
return WLAN_STATUS_UNSPECIFIED_FAILURE;
|
||||
}
|
||||
|
||||
// Update the PMKID in the STA's WPA state machine
|
||||
os_memcpy(sta->wpa_sm->pmkid, pmkid, PMKID_LEN);
|
||||
|
||||
Reference in New Issue
Block a user