mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
sysusers: fix memory leak when /etc/passwd contains multiple identical lines
Fixes: #8718
This commit is contained in:
parent
2dc993722b
commit
43e948eea6
@ -97,8 +97,8 @@ static int load_user_database(void) {
|
||||
return r;
|
||||
|
||||
while ((r = fgetpwent_sane(f, &pw)) > 0) {
|
||||
char *n;
|
||||
int k, q;
|
||||
char *n;
|
||||
|
||||
n = strdup(pw->pw_name);
|
||||
if (!n)
|
||||
@ -112,12 +112,12 @@ static int load_user_database(void) {
|
||||
|
||||
q = hashmap_put(database_uid, UID_TO_PTR(pw->pw_uid), n);
|
||||
if (q < 0 && q != -EEXIST) {
|
||||
if (k < 0)
|
||||
if (k <= 0)
|
||||
free(n);
|
||||
return q;
|
||||
}
|
||||
|
||||
if (q < 0 && k < 0)
|
||||
if (q <= 0 && k <= 0)
|
||||
free(n);
|
||||
}
|
||||
return r;
|
||||
@ -159,12 +159,12 @@ static int load_group_database(void) {
|
||||
|
||||
q = hashmap_put(database_gid, GID_TO_PTR(gr->gr_gid), n);
|
||||
if (q < 0 && q != -EEXIST) {
|
||||
if (k < 0)
|
||||
if (k <= 0)
|
||||
free(n);
|
||||
return q;
|
||||
}
|
||||
|
||||
if (q < 0 && k < 0)
|
||||
if (q <= 0 && k <= 0)
|
||||
free(n);
|
||||
|
||||
errno = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user