Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Jan 2025 12:27:09 GMT
From:      Olivier Certner <olce@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 73c073d99157 - stable/13 - mountd(8): parsecred(): uid:gid:... loop: Simplify a bit
Message-ID:  <202501171227.50HCR9H5052283@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=73c073d99157d587a5c50b61d63264882dec6ac5

commit 73c073d99157d587a5c50b61d63264882dec6ac5
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2024-09-26 16:16:16 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-01-17 12:24:51 +0000

    mountd(8): parsecred(): uid:gid:... loop: Simplify a bit
    
    No functional change intended.
    
    Reviewed by:    rmacklem (older version)
    Approved by:    markj (mentor)
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D46919
    
    (cherry picked from commit ae22a4bb7437019e34fc593e101a6ac14c9d7959)
---
 usr.sbin/mountd/mountd.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 492d7a5e3647..47bb5758ee1e 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -3643,7 +3643,9 @@ parsecred(char *namelist, struct expcred *cr)
 		cr->cr_uid = name_ul;
 	}
 	cr->cr_ngroups = 0;
-	while (names != NULL && *names != '\0' && cr->cr_ngroups < NGROUPS_MAX) {
+	while (names != NULL && *names != '\0') {
+		gid_t group;
+
 		name = strsep_quote(&names, ":");
 		name_ul = strtoul(name, &end, 10);
 		if (*end != '\0' || end == name) {
@@ -3651,13 +3653,16 @@ parsecred(char *namelist, struct expcred *cr)
 				syslog(LOG_ERR, "unknown group: %s", name);
 				continue;
 			}
-			groups[cr->cr_ngroups++] = gr->gr_gid;
+			group = gr->gr_gid;
 		} else {
-			groups[cr->cr_ngroups++] = name_ul;
+			group = name_ul;
+		}
+		if (cr->cr_ngroups == NGROUPS_MAX) {
+			syslog(LOG_ERR, "too many groups");
+			break;
 		}
+		groups[cr->cr_ngroups++] = group;
 	}
-	if (names != NULL && *names != '\0' && cr->cr_ngroups == NGROUPS_MAX)
-		syslog(LOG_ERR, "too many groups");
 	if (cr->cr_ngroups > SMALLNGROUPS)
 		cr->cr_groups = malloc(cr->cr_ngroups * sizeof(gid_t));
 	memcpy(cr->cr_groups, groups, cr->cr_ngroups * sizeof(gid_t));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202501171227.50HCR9H5052283>