git: 3f0b888ae3d0 - stable/14 - mountd(8): parsecred(): Groups limit: NGROUPS_MAX => NGROUPS_MAX + 1

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Thu, 16 Jan 2025 18:08:24 UTC
The branch stable/14 has been updated by olce:

URL: https://cgit.FreeBSD.org/src/commit/?id=3f0b888ae3d0b3a9bf520af9a5708d271a9198f8

commit 3f0b888ae3d0b3a9bf520af9a5708d271a9198f8
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2024-10-03 14:49:40 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-01-16 18:06:58 +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
    
    (cherry picked from commit 7f7f3b6cafac6e8ab993a14386e34991224f86f3)
---
 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 8ee8280b5d67..55db501332bf 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -3655,8 +3655,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;
@@ -3690,7 +3688,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;
 		}