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:
parent
3b86e9d52c
commit
4437f8fc77
1 changed files with 14 additions and 2 deletions
|
@ -216,7 +216,7 @@ static int hostapd_config_read_eap_user(const char *fname,
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char buf[512], *pos, *start, *pos2;
|
char buf[512], *pos, *start, *pos2;
|
||||||
int line = 0, ret = 0, num_methods;
|
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)
|
if (!fname)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -494,7 +494,7 @@ static int hostapd_config_read_eap_user(const char *fname,
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (tail == NULL) {
|
if (tail == NULL) {
|
||||||
tail = conf->eap_user = user;
|
tail = new_user = user;
|
||||||
} else {
|
} else {
|
||||||
tail->next = user;
|
tail->next = user;
|
||||||
tail = user;
|
tail = user;
|
||||||
|
@ -510,6 +510,18 @@ static int hostapd_config_read_eap_user(const char *fname,
|
||||||
|
|
||||||
fclose(f);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif /* EAP_SERVER */
|
#endif /* EAP_SERVER */
|
||||||
|
|
Loading…
Reference in a new issue