Fix a memory leak in addgroup() by ensuring the allocated memory
is freed if an error occurs. PR: bin/161510 MFC after: 4 weeks
This commit is contained in:
parent
cb04d194f4
commit
47061c1fd8
@ -190,7 +190,7 @@ addgroup(const char *grpname)
|
||||
err(1, "malloc");
|
||||
if ((ngrps = getgroups(ngrps_max, (gid_t *)grps)) < 0) {
|
||||
warn("getgroups");
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Remove requested gid from supp. list if it exists. */
|
||||
@ -204,7 +204,7 @@ addgroup(const char *grpname)
|
||||
if (setgroups(ngrps, (const gid_t *)grps) < 0) {
|
||||
PRIV_END;
|
||||
warn("setgroups");
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
PRIV_END;
|
||||
}
|
||||
@ -213,7 +213,7 @@ addgroup(const char *grpname)
|
||||
if (setgid(grp->gr_gid)) {
|
||||
PRIV_END;
|
||||
warn("setgid");
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
PRIV_END;
|
||||
grps[0] = grp->gr_gid;
|
||||
@ -228,12 +228,12 @@ addgroup(const char *grpname)
|
||||
if (setgroups(ngrps, (const gid_t *)grps)) {
|
||||
PRIV_END;
|
||||
warn("setgroups");
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
PRIV_END;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
free(grps);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user