3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 21:22:37 +01:00

eapol: Drop len parameter to eapol_sm_set_rsn/wpa

The len parameter was only used so it could be validated against ie[1],
but since it was not checked to be > 2, it must have been validated
already, the check was redundant.  In any case all users directly
passed ie[1] as len anyway.  This makes it consistent with the ie
parsers and builders which didn't require a length.
This commit is contained in:
Andrew Zaborowski 2016-10-28 05:59:56 +02:00 committed by Denis Kenzior
parent b29f333bb4
commit 424ceb58a3
3 changed files with 20 additions and 32 deletions

View File

@ -677,12 +677,12 @@ void device_connect_network(struct device *device, struct network *network,
/* RSN takes priority */ /* RSN takes priority */
if (bss->rsne) { if (bss->rsne) {
ie_build_rsne(&info, rsne_buf); ie_build_rsne(&info, rsne_buf);
eapol_sm_set_ap_rsn(sm, bss->rsne, bss->rsne[1] + 2); eapol_sm_set_ap_rsn(sm, bss->rsne);
eapol_sm_set_own_rsn(sm, rsne_buf, rsne_buf[1] + 2); eapol_sm_set_own_rsn(sm, rsne_buf);
} else { } else {
ie_build_wpa(&info, rsne_buf); ie_build_wpa(&info, rsne_buf);
eapol_sm_set_ap_wpa(sm, bss->wpa, bss->wpa[1] + 2); eapol_sm_set_ap_wpa(sm, bss->wpa);
eapol_sm_set_own_wpa(sm, rsne_buf, rsne_buf[1] + 2); eapol_sm_set_own_wpa(sm, rsne_buf);
} }
if (security == SECURITY_PSK) if (security == SECURITY_PSK)

View File

@ -801,30 +801,24 @@ void eapol_sm_set_pmk(struct eapol_sm *sm, const uint8_t *pmk)
} }
static void eapol_sm_set_ap_ie(struct eapol_sm *sm, const uint8_t *ie, static void eapol_sm_set_ap_ie(struct eapol_sm *sm, const uint8_t *ie,
size_t len, bool is_wpa) bool is_wpa)
{ {
if (ie[1] + 2u != len)
return;
l_free(sm->ap_ie); l_free(sm->ap_ie);
sm->ap_ie = l_memdup(ie, len); sm->ap_ie = l_memdup(ie, ie[1] + 2u);
sm->wpa_ie = is_wpa; sm->wpa_ie = is_wpa;
} }
static void eapol_sm_set_own_ie(struct eapol_sm *sm, const uint8_t *ie, static void eapol_sm_set_own_ie(struct eapol_sm *sm, const uint8_t *ie,
size_t len, bool is_wpa) bool is_wpa)
{ {
if (ie[1] + 2u != len)
return;
l_free(sm->own_ie); l_free(sm->own_ie);
sm->own_ie = l_memdup(ie, len); sm->own_ie = l_memdup(ie, ie[1] + 2u);
sm->wpa_ie = is_wpa; sm->wpa_ie = is_wpa;
} }
void eapol_sm_set_ap_rsn(struct eapol_sm *sm, const uint8_t *rsn_ie, size_t len) void eapol_sm_set_ap_rsn(struct eapol_sm *sm, const uint8_t *rsn_ie)
{ {
eapol_sm_set_ap_ie(sm, rsn_ie, len, false); eapol_sm_set_ap_ie(sm, rsn_ie, false);
} }
static bool eapol_sm_setup_own_ciphers(struct eapol_sm *sm, static bool eapol_sm_setup_own_ciphers(struct eapol_sm *sm,
@ -845,12 +839,11 @@ static bool eapol_sm_setup_own_ciphers(struct eapol_sm *sm,
return true; return true;
} }
bool eapol_sm_set_own_rsn(struct eapol_sm *sm, const uint8_t *rsn_ie, bool eapol_sm_set_own_rsn(struct eapol_sm *sm, const uint8_t *rsn_ie)
size_t len)
{ {
struct ie_rsn_info info; struct ie_rsn_info info;
eapol_sm_set_own_ie(sm, rsn_ie, len, false); eapol_sm_set_own_ie(sm, rsn_ie, false);
if (ie_parse_rsne_from_data(rsn_ie, rsn_ie[1] + 2, &info) < 0) if (ie_parse_rsne_from_data(rsn_ie, rsn_ie[1] + 2, &info) < 0)
return false; return false;
@ -858,17 +851,16 @@ bool eapol_sm_set_own_rsn(struct eapol_sm *sm, const uint8_t *rsn_ie,
return eapol_sm_setup_own_ciphers(sm, &info); return eapol_sm_setup_own_ciphers(sm, &info);
} }
void eapol_sm_set_ap_wpa(struct eapol_sm *sm, const uint8_t *wpa_ie, size_t len) void eapol_sm_set_ap_wpa(struct eapol_sm *sm, const uint8_t *wpa_ie)
{ {
eapol_sm_set_ap_ie(sm, wpa_ie, len, true); eapol_sm_set_ap_ie(sm, wpa_ie, true);
} }
bool eapol_sm_set_own_wpa(struct eapol_sm *sm, const uint8_t *wpa_ie, bool eapol_sm_set_own_wpa(struct eapol_sm *sm, const uint8_t *wpa_ie)
size_t len)
{ {
struct ie_rsn_info info; struct ie_rsn_info info;
eapol_sm_set_own_ie(sm, wpa_ie, len, true); eapol_sm_set_own_ie(sm, wpa_ie, true);
if (ie_parse_wpa_from_data(wpa_ie, wpa_ie[1] + 2, &info) < 0) if (ie_parse_wpa_from_data(wpa_ie, wpa_ie[1] + 2, &info) < 0)
return false; return false;

View File

@ -197,14 +197,10 @@ void eapol_sm_set_pmk(struct eapol_sm *sm, const uint8_t *pmk);
void eapol_sm_set_8021x_config(struct eapol_sm *sm, void eapol_sm_set_8021x_config(struct eapol_sm *sm,
struct l_settings *settings); struct l_settings *settings);
void eapol_sm_set_use_eapol_start(struct eapol_sm *sm, bool enabled); void eapol_sm_set_use_eapol_start(struct eapol_sm *sm, bool enabled);
void eapol_sm_set_ap_rsn(struct eapol_sm *sm, const uint8_t *rsn_ie, void eapol_sm_set_ap_rsn(struct eapol_sm *sm, const uint8_t *rsn_ie);
size_t len); bool eapol_sm_set_own_rsn(struct eapol_sm *sm, const uint8_t *rsn_ie);
bool eapol_sm_set_own_rsn(struct eapol_sm *sm, const uint8_t *rsn_ie, void eapol_sm_set_ap_wpa(struct eapol_sm *sm, const uint8_t *wpa_ie);
size_t len); bool eapol_sm_set_own_wpa(struct eapol_sm *sm, const uint8_t *wpa_ie);
void eapol_sm_set_ap_wpa(struct eapol_sm *sm, const uint8_t *wpa_ie,
size_t len);
bool eapol_sm_set_own_wpa(struct eapol_sm *sm, const uint8_t *wpa_ie,
size_t len);
void eapol_sm_set_user_data(struct eapol_sm *sm, void *user_data); void eapol_sm_set_user_data(struct eapol_sm *sm, void *user_data);
void eapol_sm_set_event_func(struct eapol_sm *sm, eapol_sm_event_func_t func); void eapol_sm_set_event_func(struct eapol_sm *sm, eapol_sm_event_func_t func);