Details

[Home]

Issue of the Standard # S0525

Brief

getgrouplist() updates ngroups incorrectly if there was not sufficient room to copy all the supplementary group identifiers

Detailed Description

According to LSB 3.1 standard if there was not sufficient room to copy all the supplementary group identifiers, getgrouplist() shall return -1, and update the value referenced by ngroups to the number actually copied.
But on Red Hat 4 user 'root' is a member of 8 groups and if the supplied array has size 2, then -1 will be returned and ngroups will be set to 8.
The following code shows it.

#include <stdio.h> #include <grp.h> #include <sys/types.h> int main(int argc, char* argv[]) { gid_t groups[2]; int ngroups=2; int res; res=getgrouplist("root", 1000, groups, &ngroups); printf("res=%d\n", res); printf("ngroups=%d\n", ngroups); return 0; }

Problem location(s) in the standard

Linux Standard Base Core Specification 3.1, Chapter 13. Base Libraries, 13.5. Interface Definitions for libc, description of getgrouplist().

Possible solutions

LSB standard correction

References

No references to this problem found

Accepted

LSB Bugzilla, 1639

Status

Fixed in LSB 3.1 Update 1

[Home]