mirror of git://anongit.mindrot.org/openssh.git
Handle GIDs > 2^31 in getgrouplist.
When compiled in 32bit mode, the getgrouplist implementation may fail for GIDs greater than LONG_MAX. Analysis and change from ralf.winkel at tui.com.
This commit is contained in:
parent
31fac20c94
commit
acb2887a76
|
@ -445,7 +445,7 @@ getgrouplist(const char *user, gid_t pgid, gid_t *groups, int *grpcnt)
|
|||
char *cp, *grplist, *grp;
|
||||
gid_t gid;
|
||||
int ret = 0, ngroups = 0, maxgroups;
|
||||
long l;
|
||||
long long ll;
|
||||
|
||||
maxgroups = *grpcnt;
|
||||
|
||||
|
@ -463,12 +463,12 @@ getgrouplist(const char *user, gid_t pgid, gid_t *groups, int *grpcnt)
|
|||
|
||||
/* copy each entry from getgrset into group list */
|
||||
while ((grp = strsep(&grplist, ",")) != NULL) {
|
||||
l = strtol(grp, NULL, 10);
|
||||
if (ngroups >= maxgroups || l == LONG_MIN || l == LONG_MAX) {
|
||||
ll = strtoll(grp, NULL, 10);
|
||||
if (ngroups >= maxgroups || ll < 0 || ll > UID_MAX) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
gid = (gid_t)l;
|
||||
gid = (gid_t)ll;
|
||||
if (gid == pgid)
|
||||
continue; /* we have already added primary gid */
|
||||
groups[ngroups++] = gid;
|
||||
|
|
Loading…
Reference in New Issue