git: 7f7f3b6cafac - main - mountd(8): parsecred(): Groups limit: NGROUPS_MAX => NGROUPS_MAX + 1

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Mon, 16 Dec 2024 14:45:27 UTC
The branch main has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=7f7f3b6cafac6e8ab993a14386e34991224f86f3

commit 7f7f3b6cafac6e8ab993a14386e34991224f86f3
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2024-10-03 14:49:40 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2024-12-16 14:42:30 +0000

    mountd(8): parsecred(): Groups limit: NGROUPS_MAX => NGROUPS_MAX + 1
    
    Lift this unnecessary limitation.
    
    Approved by:    markj (mentor)
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D46921
---
 usr.sbin/mountd/mountd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 585eb266e261..76a5fc6fae93 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -3653,8 +3653,6 @@ parsecred(char *namelist, struct expcred *cr)
 			ngroups = NGROUPS_MAX + 1;
 		}
 
-		if (ngroups > NGROUPS_MAX)
-			ngroups = NGROUPS_MAX;
 		if (ngroups > SMALLNGROUPS)
 			cr->cr_groups = malloc(ngroups * sizeof(gid_t));
 		cr->cr_ngroups = ngroups;
@@ -3688,7 +3686,7 @@ parsecred(char *namelist, struct expcred *cr)
 		} else {
 			group = name_ul;
 		}
-		if (cr->cr_ngroups == NGROUPS_MAX) {
+		if (cr->cr_ngroups == NGROUPS_MAX + 1) {
 			syslog(LOG_ERR, "too many groups");
 			break;
 		}