The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=551191e14e223e1cbee5e9f72e08d4e2576b9127

commit 551191e14e223e1cbee5e9f72e08d4e2576b9127
Author:     Mark Johnston <[email protected]>
AuthorDate: 2025-11-17 16:45:11 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2025-11-18 16:24:20 +0000

    setaudit: Fix handling of numeric UIDs
    
    The usage of strtoul() was incorrect.
    
    Reviewed by:    csjp
    MFC after:      2 weeks
    Sponsored by:   Modirum MDPay
    Sponsored by:   Klara, Inc.
    Differential Revision:  https://reviews.freebsd.org/D53671
---
 usr.sbin/setaudit/setaudit.8 | 2 +-
 usr.sbin/setaudit/setaudit.c | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/setaudit/setaudit.8 b/usr.sbin/setaudit/setaudit.8
index 8d0c8716ff73..7dc3e05a4473 100644
--- a/usr.sbin/setaudit/setaudit.8
+++ b/usr.sbin/setaudit/setaudit.8
@@ -45,7 +45,7 @@ Use IPv4.
 .It Fl 6
 Use IPv6.
 .It Fl a Ar auid
-Audit user ID.
+Audit user ID or user name.
 .It Fl m Ar mask
 String representation of an audit mask.
 .It Fl s Ar source
diff --git a/usr.sbin/setaudit/setaudit.c b/usr.sbin/setaudit/setaudit.c
index bdf33ab4cf3d..adea52a83a8d 100644
--- a/usr.sbin/setaudit/setaudit.c
+++ b/usr.sbin/setaudit/setaudit.c
@@ -58,7 +58,7 @@ main(int argc, char *argv [])
        auditinfo_addr_t aia;
        struct addrinfo *res;
        struct passwd *pwd;
-       char *aflag, *mflag, *sflag, *r, *prog;
+       char *aflag, *mflag, *sflag, *prog;
        int ch, error;
 
        aflag = mflag = sflag = NULL;
@@ -99,8 +99,10 @@ main(int argc, char *argv [])
        if (aflag) {
                pwd = getpwnam(aflag);
                if (pwd == NULL) {
+                       char *r;
+
                        aia.ai_auid = strtoul(aflag, &r, 10);
-                       if (r != NULL)
+                       if (*r != '\0')
                                errx(1, "%s: invalid user", aflag);
                } else
                        aia.ai_auid = pwd->pw_uid;

Reply via email to