aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd/config_file.c
diff options
context:
space:
mode:
authorStefan Tomanek <stefan.tomanek@wertarbyte.de>2015-01-19 22:57:41 (GMT)
committerJouni Malinen <j@w1.fi>2015-02-21 15:11:15 (GMT)
commit891dfb333699db01679b5fc38344186ad21243b2 (patch)
tree5d7bf0b4c36a74bf702939d64226b2fc4f032ebc /hostapd/config_file.c
parentcfb5576d9343a1b0605e0a3024d3194daa74ed9e (diff)
downloadhostap-891dfb333699db01679b5fc38344186ad21243b2.zip
hostap-891dfb333699db01679b5fc38344186ad21243b2.tar.gz
hostap-891dfb333699db01679b5fc38344186ad21243b2.tar.bz2
Add helper function to clear and free wpa_psk list
This change adds the function hostapd_config_clear_wpa_psk() that deletes an entire wpa_psk structure, making sure to follow the linked list and to free the allocated memory of each PSK node. This helps to prevent memory leaks when using PSKs from multiple sources and reconfiguring the AP during runtime. Signed-off-by: Stefan Tomanek <stefan.tomanek@wertarbyte.de>
Diffstat (limited to 'hostapd/config_file.c')
-rw-r--r--hostapd/config_file.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index 3466f28..9edbe63 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -2325,12 +2325,11 @@ static int hostapd_config_fill(struct hostapd_config *conf,
os_free(bss->ssid.wpa_passphrase);
bss->ssid.wpa_passphrase = os_strdup(pos);
if (bss->ssid.wpa_passphrase) {
- os_free(bss->ssid.wpa_psk);
- bss->ssid.wpa_psk = NULL;
+ hostapd_config_clear_wpa_psk(&bss->ssid.wpa_psk);
bss->ssid.wpa_passphrase_set = 1;
}
} else if (os_strcmp(buf, "wpa_psk") == 0) {
- os_free(bss->ssid.wpa_psk);
+ hostapd_config_clear_wpa_psk(&bss->ssid.wpa_psk);
bss->ssid.wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
if (bss->ssid.wpa_psk == NULL)
return 1;
@@ -2338,8 +2337,7 @@ static int hostapd_config_fill(struct hostapd_config *conf,
pos[PMK_LEN * 2] != '\0') {
wpa_printf(MSG_ERROR, "Line %d: Invalid PSK '%s'.",
line, pos);
- os_free(bss->ssid.wpa_psk);
- bss->ssid.wpa_psk = NULL;
+ hostapd_config_clear_wpa_psk(&bss->ssid.wpa_psk);
return 1;
}
bss->ssid.wpa_psk->group = 1;