mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 15:17:01 +02:00
BUG/MINOR: auth: Fix a leak on error path when parsing user's groups
In a userlist section, when a user is parsed, if a specified group is not found, an error is reported. In this case we must take care to release the alredy built groups list. It was reported by Coverity in #2841: CID 1587770. This patch could be backported to all stable versions.
This commit is contained in:
parent
a1e14d2a82
commit
a7f513af91
12
src/auth.c
12
src/auth.c
@ -147,7 +147,11 @@ int userlist_postinit()
|
|||||||
if (!ag) {
|
if (!ag) {
|
||||||
ha_alert("userlist '%s': no such group '%s' specified in user '%s'\n",
|
ha_alert("userlist '%s': no such group '%s' specified in user '%s'\n",
|
||||||
curuserlist->name, group, curuser->user);
|
curuserlist->name, group, curuser->user);
|
||||||
free(groups);
|
while (groups) {
|
||||||
|
grl = groups;
|
||||||
|
groups = groups->next;
|
||||||
|
free(grl);
|
||||||
|
}
|
||||||
return ERR_ALERT | ERR_FATAL;
|
return ERR_ALERT | ERR_FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +160,11 @@ int userlist_postinit()
|
|||||||
if (!grl) {
|
if (!grl) {
|
||||||
ha_alert("userlist '%s': no more memory when trying to allocate the user groups.\n",
|
ha_alert("userlist '%s': no more memory when trying to allocate the user groups.\n",
|
||||||
curuserlist->name);
|
curuserlist->name);
|
||||||
free(groups);
|
while (groups) {
|
||||||
|
grl = groups;
|
||||||
|
groups = groups->next;
|
||||||
|
free(grl);
|
||||||
|
}
|
||||||
return ERR_ALERT | ERR_FATAL;
|
return ERR_ALERT | ERR_FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user