svn commit: r356217 - head/usr.sbin/inetd
Kyle Evans
kevans at FreeBSD.org
Tue Dec 31 04:36:15 UTC 2019
Author: kevans
Date: Tue Dec 31 04:36:14 2019
New Revision: 356217
URL: https://svnweb.freebsd.org/changeset/base/356217
Log:
inetd: prefer strtonum(3) to strspn(3)+atoi(3), NFC
strtonum(3) does effectively the same validation as we had, but it's more
concise.
Modified:
head/usr.sbin/inetd/builtins.c
Modified: head/usr.sbin/inetd/builtins.c
==============================================================================
--- head/usr.sbin/inetd/builtins.c Tue Dec 31 04:16:52 2019 (r356216)
+++ head/usr.sbin/inetd/builtins.c Tue Dec 31 04:36:14 2019 (r356217)
@@ -649,8 +649,14 @@ ident_stream(int s, struct servtab *sep)
goto fakeid_fail;
if (!Fflag) {
if (iflag) {
- if (p[strspn(p, "0123456789")] == '\0' &&
- getpwuid(atoi(p)) != NULL)
+ const char *errstr;
+ uid_t uid;
+
+ uid = strtonum(p, 0, UID_MAX, &errstr);
+ if (errstr != NULL)
+ goto fakeid_fail;
+
+ if (getpwuid(uid) != NULL)
goto fakeid_fail;
} else {
if (getpwnam(p) != NULL)
More information about the svn-src-all
mailing list