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.
This commit is contained in:
parent
8acd3f126a
commit
1c3b9acf2e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=356217
@ -649,8 +649,14 @@ ident_stream(int s, struct servtab *sep)
|
|||||||
goto fakeid_fail;
|
goto fakeid_fail;
|
||||||
if (!Fflag) {
|
if (!Fflag) {
|
||||||
if (iflag) {
|
if (iflag) {
|
||||||
if (p[strspn(p, "0123456789")] == '\0' &&
|
const char *errstr;
|
||||||
getpwuid(atoi(p)) != NULL)
|
uid_t uid;
|
||||||
|
|
||||||
|
uid = strtonum(p, 0, UID_MAX, &errstr);
|
||||||
|
if (errstr != NULL)
|
||||||
|
goto fakeid_fail;
|
||||||
|
|
||||||
|
if (getpwuid(uid) != NULL)
|
||||||
goto fakeid_fail;
|
goto fakeid_fail;
|
||||||
} else {
|
} else {
|
||||||
if (getpwnam(p) != NULL)
|
if (getpwnam(p) != NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user