We still need to clamp ngids if getgrouplist2() returns -1.
Otherwise, we end up with ngids set to the number of gids the user belongs to which may be larger than what the front-end specified. Fixes a regression introduced in the last commit here.
This commit is contained in:
@@ -307,8 +307,9 @@ PREFIX(make_gidlist_item)(const struct passwd *pw, char * const *gidstrs,
|
|||||||
"unable to allocate memory");
|
"unable to allocate memory");
|
||||||
debug_return_ptr(NULL);
|
debug_return_ptr(NULL);
|
||||||
}
|
}
|
||||||
/* getgrouplist2() returns failure if it can't store all groups. */
|
/* Clamp to max_groups if insufficient space for all groups. */
|
||||||
(void)PREFIX(getgrouplist2)(pw->pw_name, pw->pw_gid, &gids, &ngids);
|
if (PREFIX(getgrouplist2)(pw->pw_name, pw->pw_gid, &gids, &ngids) == -1)
|
||||||
|
ngids = sudo_pwutil_get_max_groups();
|
||||||
} else {
|
} else {
|
||||||
gids = NULL;
|
gids = NULL;
|
||||||
if (PREFIX(getgrouplist2)(pw->pw_name, pw->pw_gid, &gids, &ngids) == -1) {
|
if (PREFIX(getgrouplist2)(pw->pw_name, pw->pw_gid, &gids, &ngids) == -1) {
|
||||||
|
Reference in New Issue
Block a user