mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-29 01:22:53 +00:00
BUG/MEDIUM: uri_auth: missing NULL check and memory leak on memory shortage
A test is obviously wrong in uri_auth(). If strdup(pass) returns an error while strdup(user) passes, the NULL pointer is still stored into the structure. If the user returns the NULL instead, the allocated memory is not released before returning the error. The issue was present in 1.4 so the fix should be backported. Reported-by: Dinko Korunic <dkorunic@reflected.net>
This commit is contained in:
parent
de2dd6b125
commit
0b291bdef1
@ -247,12 +247,19 @@ struct uri_auth *stats_add_auth(struct uri_auth **root, char *user)
|
||||
return NULL;
|
||||
|
||||
newuser->user = strdup(user);
|
||||
newuser->pass = strdup(pass);
|
||||
newuser->flags |= AU_O_INSECURE;
|
||||
|
||||
if (!newuser->user || !newuser->user)
|
||||
if (!newuser->user) {
|
||||
free(newuser);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
newuser->pass = strdup(pass);
|
||||
if (!newuser->pass) {
|
||||
free(newuser->user);
|
||||
free(newuser);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
newuser->flags |= AU_O_INSECURE;
|
||||
newuser->next = u->userlist->users;
|
||||
u->userlist->users = newuser;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user