diff --git a/wpa_supplicant-2.9_standard/src/eap_common/ext_authentication.c b/wpa_supplicant-2.9_standard/src/eap_common/ext_authentication.c index d2af5f849dd079d4a8cab93a032981a4a80f1689..93c3b1b9cd756c1f2dc6efc618997c4361de2d9b 100644 --- a/wpa_supplicant-2.9_standard/src/eap_common/ext_authentication.c +++ b/wpa_supplicant-2.9_standard/src/eap_common/ext_authentication.c @@ -21,6 +21,15 @@ const char *g_ifnameToString[] = { "eth0" }; +const char *ifname_to_string(int ifname) +{ + if (ifname <= IFNAME_UNKNOWN || ifname >= IFNAME_SIZE) { + wpa_printf(MSG_ERROR, "ext_certification ifname_to_string : ifname : %d", ifname); + return g_ifnameToString[0]; + } + return g_ifnameToString[ifname]; +} + bool reg_ext_auth(int code, int type, int ifname) { wpa_printf(MSG_INFO, "ext_certification reg_ext_auth : code : %d , type : %d, ifname : %d", code, type, ifname); @@ -128,7 +137,7 @@ struct eap_sm* get_eap_sm() static struct encrypt_data g_encryptData; void set_encrypt_data(struct eap_ssl_data *ssl, int eapType, int version, unsigned char id) { - wpa_printf(MSG_DEBUG, "ext_certification set_encrypt_data : eapType : %d , version : %d", eapType, + wpa_printf(MSG_DEBUG, "ext_certification set_encrypt_data : eapType : %d , version : %d, id : %hhu", eapType, vertion, (u8)id); g_encryptData.ssl = ssl; g_encryptData.eapType = eapType; @@ -151,11 +160,13 @@ int g_code = 0; int get_code() { + wpa_printf(MSG_DEBUG, "ext_certification get_code : code : %d", g_code); return g_code; } void set_code(int code) { + wpa_printf(MSG_DEBUG, "ext_certification set_code : code : %d", code); g_code = code; } diff --git a/wpa_supplicant-2.9_standard/src/eap_common/ext_authentication.h b/wpa_supplicant-2.9_standard/src/eap_common/ext_authentication.h index 1de63b2eeed48f0c183992382a4f7dfa2a0bb505..ba5d71db1b36916cd0b11f92377d4d9155afa519 100644 --- a/wpa_supplicant-2.9_standard/src/eap_common/ext_authentication.h +++ b/wpa_supplicant-2.9_standard/src/eap_common/ext_authentication.h @@ -21,11 +21,11 @@ enum Ifname { IFNAME_SIZE = 3 }; - extern const char* g_ifnameToString[]; +const char *ifname_to_string(int ifname); - bool reg_ext_auth(int code, int type, int ifname); - bool un_reg_ext_auth(int code, int type); - int get_ext_auth(int code, int type); +bool reg_ext_auth(int code, int type, int ifname); +bool un_reg_ext_auth(int code, int type); +int get_ext_auth(int code, int type); // 递增的数字标识符 int get_authentication_idx(); @@ -37,7 +37,7 @@ void clear_eap_data(); void set_eap_data(uint8_t* eapData, int eapDataLen); struct eap_sm; -void set_eap_sm(struct eap *eapSm); +void set_eap_sm(struct eap_sm *eapSm); struct eap_sm* get_eap_sm(); struct eap_ssl_data; diff --git a/wpa_supplicant-2.9_standard/src/eap_peer/eap.c b/wpa_supplicant-2.9_standard/src/eap_peer/eap.c index f1b5b2400d78683f61eeeefe7a74fcd8187c41c9..77b92cef130f700866f8186da3030f205e58d8b6 100644 --- a/wpa_supplicant-2.9_standard/src/eap_peer/eap.c +++ b/wpa_supplicant-2.9_standard/src/eap_peer/eap.c @@ -908,7 +908,12 @@ static void tx_ext_certification(STATE_MACHINE_DATA *sm) wpa_printf(MSG_DEBUG, "ext_certification tx_ext_certification %u:2:%d", get_authentication_idx(), sm->eapRespData->buf[TYPE_OFFSET]); int ifname = get_ext_auth(EAP_CODE_RESPONSE, (int)(sm->eapRespData->buf[TYPE_OFFSET])); - if (ifname == IFNAME_UNKNOWN || ifname >= IFNAME_SIZE) { + if (ifname == IFNAME_UNKNOWN) { + eapol_set_bool(sm, EAPOL_eapResp, true); + return; + } + if (ifname < IFNAME_UNKNOWN || ifname >= IFNAME_SIZE) { + wpa_printf(MSG_ERROR, "ext_certification tx_ext_certification ifname error : %d", ifname); eapol_set_bool(sm, EAPOL_eapResp, true); return; } @@ -937,7 +942,7 @@ static void tx_ext_certification(STATE_MACHINE_DATA *sm) return; } - WpaEventReport(g_ifnameToString[ifname], WPA_EVENT_STA_NOTIFY, (void *) param); + WpaEventReport(ifname_to_string(ifname), WPA_EVENT_STA_NOTIFY, (void *) param); clear_eap_data(); eapol_set_bool(sm, EAPOL_eapResp, false); #endif diff --git a/wpa_supplicant-2.9_standard/src/eapol_supp/eapol_supp_sm.c b/wpa_supplicant-2.9_standard/src/eapol_supp/eapol_supp_sm.c index 94f27bde1d14bba0cfa7c982e3566abd05059a47..ecd6c881fd3facfe0efb4c3d125e5e01f44f8e6f 100644 --- a/wpa_supplicant-2.9_standard/src/eapol_supp/eapol_supp_sm.c +++ b/wpa_supplicant-2.9_standard/src/eapol_supp/eapol_supp_sm.c @@ -1180,7 +1180,12 @@ static void rx_ext_certification(struct eapol_sm *sm) wpa_printf(MSG_DEBUG, "ext_certification rx_ext_certification %u:1:%d", get_authentication_idx(), sm->eapReqData->buf[TYPE_OFFSET]); int ifname = get_ext_auth(EAP_CODE_REQUEST, (int)(sm->eapReqData->buf[TYPE_OFFSET])); - if (ifname == IFNAME_UNKNOWN || ifname >= IFNAME_SIZE) { + if (ifname == IFNAME_UNKNOWN) { + eapol_sm_step(sm); + return; + } + if (ifname < IFNAME_UNKNOWN || ifname >= IFNAME_SIZE) { + wpa_printf(MSG_ERROR, "ext_certification rx_ext_certification ifname error : %d", ifname); eapol_sm_step(sm); return; } @@ -1188,7 +1193,7 @@ static void rx_ext_certification(struct eapol_sm *sm) set_eap_sm(sm); size_t length = PARAM_LEN + (size_t)((sm->eapReqData->size + BASE64_NUM - 1) / BASE64_NUM * (BASE64_NUM + 1)); if (length > BUF_SIZE) { - wpa_printf(MSG_ERROR, "ext_certification rx_ext_certification ptr is NULL"); + wpa_printf(MSG_ERROR, "ext_certification rx_ext_certification length error"); return; } #ifdef CONFIG_LIBWPA_VENDOR @@ -1206,7 +1211,7 @@ static void rx_ext_certification(struct eapol_sm *sm) return; } free(base64Parm); - WpaEventReport(g_ifnameToString[ifname], WPA_EVENT_STA_NOTIFY, (void *)param); + WpaEventReport(ifname_to_string(ifname), WPA_EVENT_STA_NOTIFY, (void *)param); #endif } #endif /* EXT_AUTHENTICATION_SUPPORT */ diff --git a/wpa_supplicant-2.9_standard/wpa_supplicant/ctrl_iface.c b/wpa_supplicant-2.9_standard/wpa_supplicant/ctrl_iface.c index b6cc3ffc632dedf9db0c15456b9f18187444ab80..f0e857b69250a22723d384d69f177735bd4aad77 100644 --- a/wpa_supplicant-2.9_standard/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant-2.9_standard/wpa_supplicant/ctrl_iface.c @@ -12821,9 +12821,9 @@ static int ext_auth_reg(char *params) if (datas != NULL) { // 输出解析结果 for (int i = 0; i < count; ++i) { - int value = datas[i]; - uint type = ((int64_t)value) & ((1 << EXT_OFFSET) - 1); - uint code = ((int64_t)value) >> EXT_OFFSET; + uint value = (uint)datas[i]; + uint type = value & ((1 << EXT_OFFSET) - 1); + uint code = value >> EXT_OFFSET; wpa_printf(MSG_DEBUG, "ext_certification EXT_AUTH_REG_PREFIX: value: %d, %u, %u", value, type, code); reg_ext_auth(code, type, ifname); } @@ -12843,9 +12843,9 @@ static int ext_auth_unreg(char *params) if (datas != NULL) { // 输出解析结果 for (int i = 0; i < count; ++i) { - int value = datas[i]; - uint type = ((int64_t)value) & ((1 << EXT_OFFSET) - 1); - uint code = ((int64_t)value) >> EXT_OFFSET; + uint value = (uint)datas[i]; + uint type = value & ((1 << EXT_OFFSET) - 1); + uint code = value >> EXT_OFFSET; wpa_printf(MSG_DEBUG, "ext_certification EXT_AUTH_UNREG_PREFIX_SIZE: value: %d, %u, %u", value, type, code); un_reg_ext_auth(code, type); @@ -12866,11 +12866,6 @@ static int ext_auth_data_inner(struct wpa_supplicant * wpa_s, u8* dataBuf, int r eapol_sm_notify_eap_fail(wpa_s->eapol, true); return 0; } - if (result == EXT_AUTH_FINISH) { - wpa_printf(MSG_DEBUG, "ext_auth_data_inner EXT_AUTH_FINISH"); - eapol_sm_notify_eap_success(wpa_s->eapol, true); - return 0; - } // 修改sm if (code == EAP_CODE_REQUEST) { wpa_printf(MSG_DEBUG, "ext_certification code = EAP_CODE_REQUEST"); @@ -12926,7 +12921,7 @@ static int ext_auth_data(struct wpa_supplicant *wpa_s, char *params) size_t count = 0; u8* databuf = base64_decode(params + startIdx, strlen(params + startIdx), &count); - bool illegal = (count != bufferLen) || (get_authentication_idx() != (int)idx) ||(dataBuf == NULL); + bool illegal = (count != bufferLen) || (get_authentication_idx() != (int)idx) || (dataBuf == NULL); if (illegal) { os_free(dataBuf); dataBuf = NULL;