File tree Expand file tree Collapse file tree 1 file changed +2
-13
lines changed Expand file tree Collapse file tree 1 file changed +2
-13
lines changed Original file line number Diff line number Diff line change @@ -1486,19 +1486,8 @@ pub fn getgrouplist(user: &CStr, group: Gid) -> Result<Vec<Gid>> {
14861486 // BSD systems will still fill the groups buffer with as many
14871487 // groups as possible, but Linux manpages do not mention this
14881488 // behavior.
1489-
1490- let cap = groups. capacity ( ) ;
1491- if cap >= ngroups_max as usize {
1492- // We already have the largest capacity we can, give up
1493- return Err ( Error :: invalid_argument ( ) ) ;
1494- }
1495-
1496- // Reserve space for at least ngroups
1497- groups. reserve ( ngroups as usize ) ;
1498-
1499- // Even if the buffer gets resized to bigger than ngroups_max,
1500- // don't ever ask for more than ngroups_max groups
1501- ngroups = min ( ngroups_max, groups. capacity ( ) as c_int ) ;
1489+ reserve_double_buffer_size ( & mut groups, ngroups_max as usize )
1490+ . or_else ( |_| Err ( Error :: invalid_argument ( ) ) ) ?;
15021491 }
15031492 }
15041493}
You can’t perform that action at this time.
0 commit comments