Fix memcpy regression in PMK handling
The memcpy calls added for exposing the PMK from wpa_auth module could
end up trying to copy the same memory buffer on top of itself.
Overlapping memory areas are not allowed with memcpy, so this could
result in undefined behavior. Fix this by making the copies conditional
on the updated value actually coming from somewhere else.
Fixes: b08c9ad0c7
("AP: Expose PMK outside of wpa_auth module")
Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
130444738b
commit
08dc8efd29
1 changed files with 8 additions and 4 deletions
|
@ -892,8 +892,10 @@ static int wpa_try_alt_snonce(struct wpa_state_machine *sm, u8 *data,
|
||||||
|
|
||||||
if (wpa_verify_key_mic(sm->wpa_key_mgmt, pmk_len, &PTK,
|
if (wpa_verify_key_mic(sm->wpa_key_mgmt, pmk_len, &PTK,
|
||||||
data, data_len) == 0) {
|
data, data_len) == 0) {
|
||||||
os_memcpy(sm->PMK, pmk, pmk_len);
|
if (sm->PMK != pmk) {
|
||||||
sm->pmk_len = pmk_len;
|
os_memcpy(sm->PMK, pmk, pmk_len);
|
||||||
|
sm->pmk_len = pmk_len;
|
||||||
|
}
|
||||||
ok = 1;
|
ok = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2791,8 +2793,10 @@ SM_STATE(WPA_PTK, PTKCALCNEGOTIATING)
|
||||||
wpa_verify_key_mic(sm->wpa_key_mgmt, pmk_len, &PTK,
|
wpa_verify_key_mic(sm->wpa_key_mgmt, pmk_len, &PTK,
|
||||||
sm->last_rx_eapol_key,
|
sm->last_rx_eapol_key,
|
||||||
sm->last_rx_eapol_key_len) == 0) {
|
sm->last_rx_eapol_key_len) == 0) {
|
||||||
os_memcpy(sm->PMK, pmk, pmk_len);
|
if (sm->PMK != pmk) {
|
||||||
sm->pmk_len = pmk_len;
|
os_memcpy(sm->PMK, pmk, pmk_len);
|
||||||
|
sm->pmk_len = pmk_len;
|
||||||
|
}
|
||||||
ok = 1;
|
ok = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue