From nobody Mon Dec 16 14:45:22 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YBjR71H8xz5hWSN; Mon, 16 Dec 2024 14:45:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YBjR65jkQz4ccT; Mon, 16 Dec 2024 14:45:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734360322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9DmuHx4zV2pgVnYpkw4Dto8bHJ4e0Tq0euCCSfw52/k=; b=MA3oqmCanHJnRt51TdMmbQ2R7/NzqCXlnmks+7XOd41yhTWLx9uVUqqmosCUWV12I7DvqD O0Dp2+hGKtnewj/YSE/W6PrYtgDzsZ/n6wSir72WaLpQgwIVrOt+OvI4BWpxvSNWg5P5Jr cNLyWsK/A2okm5wFb8QlXick5rifgORXZeiokaFuYjcdAca041kMoCovXOzHKqW0xgiDtn Vu+P3+xFh7k+1tcZ062h+cya3dOh7XXRq4gMON5aFU7YelMB3bBgMFHptaKXVQ+beyfA+h DYLHQ2ab0OhGfKfLRzthN/XbFLNKB3LsJoNiUBVP1K4vtnMjJNRU+orKh1nHTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734360322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9DmuHx4zV2pgVnYpkw4Dto8bHJ4e0Tq0euCCSfw52/k=; b=ucsxEII3knpBtmOpk+VHVcoVQEm8J6GGls4wGf3XdbH/DkbooKcpZAfcgkkl46I83a1FjD Zy/lAOxWFmcjFALxZ2NHaXrFNVI5XW1A+3nBg7iBm7nPsj+V+TglAgHNZJ9MEGALXjycwf ndnEl9Sdz55zzRKSVCVDESJPDjXyWwfmxYxSyCCLFbMqDJDQD+PqUP8JbINdKlF+YNGf8w 9hmpfdxc44ki+wwHj7wzXhwZ7fWKpxpSGz9DdoL87bBeB22V0wdCbvL6V/03aBsCy9sbxk pm8tZRXJVOdhzqA5doW3pZOGWfcTChztzDi7Dq+Wsp+PFQp/STO45j8o6uQ+8A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734360322; a=rsa-sha256; cv=none; b=ppEJEgWil3yqpifQDGsjPrs5cr3pD0Yr5ubcchzhI3Kx/YIv6Lczc/ku6twBV6yK5uUhaG xkmYUphd7QMv5yNEmYaBtpZgyGIwOaK49p3t/pGOudnxPn+z7S0hfK8zitq/ntl7xz7nnx tKenXayeDJM0XUpnUWJ0vcGobq7FJTEH3AHoOlng7uOC5seyzv2HI500D2sNn4OTZekkhj ALlBP1mmzmR+0CFHuWzDHeduDDj3BZdi+ZGRoDi2uFi1ZFkBCaR63pnxqfVJZqIycptBKx dzD4pV2Q9JMBA5qeBx0TWmpXjTLVg8Dv96mp3ExORbZta04U9ciWu3CvcEgrEQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YBjR65HmDzxWq; Mon, 16 Dec 2024 14:45:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BGEjMiq051793; Mon, 16 Dec 2024 14:45:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BGEjM7r051790; Mon, 16 Dec 2024 14:45:22 GMT (envelope-from git) Date: Mon, 16 Dec 2024 14:45:22 GMT Message-Id: <202412161445.4BGEjM7r051790@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: ae22a4bb7437 - main - mountd(8): parsecred(): uid:gid:... loop: Simplify a bit List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ae22a4bb7437019e34fc593e101a6ac14c9d7959 Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=ae22a4bb7437019e34fc593e101a6ac14c9d7959 commit ae22a4bb7437019e34fc593e101a6ac14c9d7959 Author: Olivier Certner AuthorDate: 2024-09-26 16:16:16 +0000 Commit: Olivier Certner CommitDate: 2024-12-16 14:42:29 +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 --- 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 00309ed58136..c903431c2ecf 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -3684,7 +3684,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) { @@ -3692,13 +3694,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));