[openssh-commits] [openssh] 01/01: Handle GIDs > 2^31 in getgrouplist.

git+noreply at mindrot.org git+noreply at mindrot.org
Thu Jun 17 21:08:35 AEST 2021


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

commit acb2887a769a1b1912cfd7067f3ce04fad240260
Author: Darren Tucker <dtucker at dtucker.net>
Date:   Thu Jun 17 21:03:19 2021 +1000

    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.
---
 openbsd-compat/port-aix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c
index e0d3eba5..2ac9bad0 100644
--- a/openbsd-compat/port-aix.c
+++ b/openbsd-compat/port-aix.c
@@ -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;

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list