]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Clear PSK explicitly from memory in couple more cases on deinit
authorJouni Malinen <quic_jouni@quicinc.com>
Sat, 26 Feb 2022 11:39:35 +0000 (13:39 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 26 Feb 2022 17:12:11 +0000 (19:12 +0200)
Couple of the WPS/P2P/RADIUS-PSK cases were freeing heap memory
allocations without explicitly clearing the PSK value. Add such clearing
for these to avoid leaving the PSK in memory after it is not needed
anymore.

Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/ap/ieee802_11_auth.c
src/ap/wps_hostapd.c
wpa_supplicant/p2p_supplicant.c

index 783ee6dea96b22357fd532d03584cff99d705e15..cf13008a1df81b5bf82eee79fde80ff38958c736 100644 (file)
@@ -646,6 +646,6 @@ void hostapd_free_psk_list(struct hostapd_sta_wpa_psk_short *psk)
        while (psk) {
                struct hostapd_sta_wpa_psk_short *prev = psk;
                psk = psk->next;
-               os_free(prev);
+               bin_clear_free(prev, sizeof(*prev));
        }
 }
index 4f1c76b7b65c45b8e2a226f5923350e09d924b07..aacfa337260a61c3b84c2da04ec65adccfee46e5 100644 (file)
@@ -1069,10 +1069,11 @@ static void hostapd_free_wps(struct wps_context *wps)
        for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++)
                wpabuf_free(wps->dev.vendor_ext[i]);
        wps_device_data_free(&wps->dev);
-       os_free(wps->network_key);
+       bin_clear_free(wps->network_key, wps->network_key_len);
        hostapd_wps_nfc_clear(wps);
        wpabuf_free(wps->dh_pubkey);
        wpabuf_free(wps->dh_privkey);
+       forced_memzero(wps->psk, sizeof(wps->psk));
        os_free(wps);
 }
 
index ce44dfb9e053da44a803a6b722533f748d37dc3a..a996b436b4297ab779edf15d9429500af641e5d8 100644 (file)
@@ -8825,7 +8825,7 @@ static void wpas_p2p_remove_client_go(struct wpa_supplicant *wpa_s,
                                hapd->conf->ssid.wpa_psk = psk->next;
                        rem = psk;
                        psk = psk->next;
-                       os_free(rem);
+                       bin_clear_free(rem, sizeof(*rem));
                } else {
                        prev = psk;
                        psk = psk->next;