If sudo_getgrouplist2() returns -1, clamp ngroups based on max_groups.
The ngroups parameter is an out parameter that is filled in with the actual number of groups, which may be less than the static number allocated when max_groups is set in sudo.conf. Fixes a potential out of bounds read found by LLVM libFuzzer.
This commit is contained in:
@@ -263,7 +263,9 @@ sudo_make_gidlist_item(const struct passwd *pw, char * const *unused1,
|
||||
"unable to allocate memory");
|
||||
debug_return_ptr(NULL);
|
||||
}
|
||||
(void)sudo_getgrouplist2(pw->pw_name, pw->pw_gid, &gids, &ngids);
|
||||
/* Clamp to max_groups if insufficient space for all groups. */
|
||||
if (sudo_getgrouplist2(pw->pw_name, pw->pw_gid, &gids, &ngids) == -1)
|
||||
ngids = sudo_user.max_groups;
|
||||
} else {
|
||||
gids = NULL;
|
||||
if (sudo_getgrouplist2(pw->pw_name, pw->pw_gid, &gids, &ngids) == -1) {
|
||||
|
Reference in New Issue
Block a user