mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-03 14:23:02 +02:00
bin: copy: use NGROUPS_MAX when probing user groups
Avoid a theoretical race between getting the number of groups a user belongs to and actually processing them. We should not need to check the return value of getgrouplist() as we know the number of groups fit inside the buffer. Signed-off-by: Richard Alpe <richard@bit42.se>
This commit is contained in:
+1
-2
@@ -114,8 +114,7 @@ static gid_t in_group(const char *user, const char *fn, gid_t *gid)
|
||||
if (stat(dir, &st))
|
||||
return 0;
|
||||
|
||||
getgrouplist(user, pw->pw_gid, NULL, &num);
|
||||
|
||||
num = NGROUPS_MAX;
|
||||
groups = malloc(num * sizeof(gid_t));
|
||||
if (!groups) {
|
||||
perror("in_group() malloc");
|
||||
|
||||
Reference in New Issue
Block a user