Use the method described in the strtol man page to check if it parsed

the entire string.  This avoids signed/unsigned comparison.
This commit is contained in:
David Malone 2002-03-30 16:24:03 +00:00
parent 4f1f485f34
commit fb757ee269

View File

@ -225,7 +225,7 @@ main(int ac, char **av)
}
if (user) {
uid = strtol(user, &ep, 10);
if ((ep - user) < strlen(user)) {
if (*user == '\0' || *ep != '\0') { /* was it a number? */
pw = getpwnam(user);
if (pw == NULL)
errx(1, "user %s does not exist", user);