]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Avoid undefined behavior with memcpy PMK/PSK update
authorJouni Malinen <jouni@codeaurora.org>
Mon, 2 Nov 2020 16:46:35 +0000 (18:46 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 2 Nov 2020 16:46:35 +0000 (18:46 +0200)
When SAE is used, the local pointer pmk may point to sm->PMK. Skip the
memcpy operation in such a case since it is not really needed and use of
overlapping memory buffers is undefined behavior for memcpy().

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/ap/wpa_auth.c

index 9d74bfcd78e24bf1aea2c0f9466763cf808fdbf9..82a97468d62dbf7631d6cc5a0231c4c1d7dae43f 100644 (file)
@@ -3145,7 +3145,7 @@ SM_STATE(WPA_PTK, PTKCALCNEGOTIATING)
        sm->pending_1_of_4_timeout = 0;
        eloop_cancel_timeout(wpa_send_eapol_timeout, sm->wpa_auth, sm);
 
-       if (wpa_key_mgmt_wpa_psk(sm->wpa_key_mgmt)) {
+       if (wpa_key_mgmt_wpa_psk(sm->wpa_key_mgmt) && sm->PMK != pmk) {
                /* PSK may have changed from the previous choice, so update
                 * state machine data based on whatever PSK was selected here.
                 */