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>
This commit is contained in:
Jouni Malinen 2015-01-30 00:54:40 +02:00 committed by Jouni Malinen
parent 3b86e9d52c
commit 4437f8fc77

View File

@ -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 */