aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd/config_file.c
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2015-01-29 22:54:40 (GMT)
committerJouni Malinen <j@w1.fi>2015-01-29 22:54:40 (GMT)
commit4437f8fc778e6272b16ad5f120ecf3ac1ac7700c (patch)
tree950d904a1c02e0dea27f2f5567e939fc6cb1f6b7 /hostapd/config_file.c
parent3b86e9d52cf6472b2ca7fba89abc234319989744 (diff)
downloadhostap-4437f8fc778e6272b16ad5f120ecf3ac1ac7700c.zip
hostap-4437f8fc778e6272b16ad5f120ecf3ac1ac7700c.tar.gz
hostap-4437f8fc778e6272b16ad5f120ecf3ac1ac7700c.tar.bz2
Free old eap_user_file data on configuration change
This fixes a memory leak if hostapd eap_user_file parameter is modified. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'hostapd/config_file.c')
-rw-r--r--hostapd/config_file.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index 7cbb46b..e3cad7c 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -216,7 +216,7 @@ static int hostapd_config_read_eap_user(const char *fname,
FILE *f;
char buf[512], *pos, *start, *pos2;
int line = 0, ret = 0, num_methods;
- struct hostapd_eap_user *user = NULL, *tail = NULL;
+ struct hostapd_eap_user *user = NULL, *tail = NULL, *new_user = NULL;
if (!fname)
return 0;
@@ -494,7 +494,7 @@ static int hostapd_config_read_eap_user(const char *fname,
done:
if (tail == NULL) {
- tail = conf->eap_user = user;
+ tail = new_user = user;
} else {
tail->next = user;
tail = user;
@@ -510,6 +510,18 @@ static int hostapd_config_read_eap_user(const char *fname,
fclose(f);
+ if (ret == 0) {
+ user = conf->eap_user;
+ while (user) {
+ struct hostapd_eap_user *prev;
+
+ prev = user;
+ user = user->next;
+ hostapd_config_free_eap_user(prev);
+ }
+ conf->eap_user = new_user;
+ }
+
return ret;
}
#endif /* EAP_SERVER */