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
This commit is contained in:
Mark Johnston
2025-11-17 16:45:11 +00:00
parent a9be8f9968
commit 551191e14e
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -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
+4 -2
View File
@@ -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;