diff options
author | Peter Valchev <pvalchev@cvs.openbsd.org> | 2004-07-19 09:22:18 +0000 |
---|---|---|
committer | Peter Valchev <pvalchev@cvs.openbsd.org> | 2004-07-19 09:22:18 +0000 |
commit | f631abc01fc3d48a099b2a2694e05e871f1ee82c (patch) | |
tree | 78af2dec48c706e3259226acea8b04eb92fb5482 /usr.bin/id | |
parent | 88ccbc1aeaae37b73864f956ce8f2dac2bc98fb6 (diff) |
use strtonum with proper bounds instead of abusing strtoul; ok millert
Diffstat (limited to 'usr.bin/id')
-rw-r--r-- | usr.bin/id/id.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/id/id.c b/usr.bin/id/id.c index c015b94ed3d..57bc8658825 100644 --- a/usr.bin/id/id.c +++ b/usr.bin/id/id.c @@ -1,4 +1,4 @@ -/* $OpenBSD: id.c,v 1.15 2004/05/31 15:48:26 pedro Exp $ */ +/* $OpenBSD: id.c,v 1.16 2004/07/19 09:22:17 pvalchev Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "@(#)id.c 8.3 (Berkeley) 4/28/95";*/ -static char rcsid[] = "$OpenBSD: id.c,v 1.15 2004/05/31 15:48:26 pedro Exp $"; +static char rcsid[] = "$OpenBSD: id.c,v 1.16 2004/07/19 09:22:17 pvalchev Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -295,7 +295,7 @@ who(char *u) { struct passwd *pw; uid_t uid; - char *ep; + const char *errstr; /* * Translate user argument into a pw pointer. First, try to @@ -303,8 +303,8 @@ who(char *u) */ if ((pw = getpwnam(u))) return(pw); - uid = strtoul(u, &ep, 10); - if (*u && !*ep && (pw = getpwuid(uid))) + uid = strtonum(u, 0, UID_MAX, &errstr); + if (!errstr && (pw = getpwuid(uid))) return(pw); errx(1, "%s: No such user", u); /* NOTREACHED */ |