From 2d392fbccfd8b4a6b9dc8f5331db5aad3092f91d Mon Sep 17 00:00:00 2001 From: Jason Coverston <jcovers@cray.com> Date: Mon, 6 Jul 2015 05:59:27 -0700 Subject: [PATCH] Fix check of getgrouplist to check the original size of array instead of the size returned. This check is redundant though since getgrouplist will return -1 if it tries to use more than ngroups_max. Perhaps we should just take the check out. --- src/slurmd/slurmstepd/mgr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/slurmd/slurmstepd/mgr.c b/src/slurmd/slurmstepd/mgr.c index 8b99219bc47..ae68e000c94 100644 --- a/src/slurmd/slurmstepd/mgr.c +++ b/src/slurmd/slurmstepd/mgr.c @@ -2583,7 +2583,9 @@ _initgroups(stepd_step_rec_t *job) if (primary_gid != job->gid) { int ngroups_max = sysconf(_SC_NGROUPS_MAX); gid_t grps[ngroups_max]; - int size; + int size, max; + + max = ngroups_max; size = getgrouplist(job->user_name, job->gid, @@ -2593,7 +2595,7 @@ _initgroups(stepd_step_rec_t *job) error("%s: getgrouplist() failed: %m", __func__); return -1; } - if (size > ngroups_max - 1) { + if (size > max - 1) { error("%s: too many groups %d for user %s\n", __func__, size, job->user_name); } -- GitLab