summaryrefslogtreecommitdiff
path: root/usr.bin/fstat
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2007-04-07 23:20:20 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2007-04-07 23:20:20 +0000
commit9f94e9d55e37418c5d78c0f9926aa6673f1fa779 (patch)
treece11e43f274a1a9ddcf81d95272402d889978d83 /usr.bin/fstat
parentc6b764f7a9d018ac40e2d03f931cea130b13d8ae (diff)
use strtonum, from jason dixon
Diffstat (limited to 'usr.bin/fstat')
-rw-r--r--usr.bin/fstat/fstat.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c
index ffb5d6223db..72fe4fd44ef 100644
--- a/usr.bin/fstat/fstat.c
+++ b/usr.bin/fstat/fstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fstat.c,v 1.57 2006/06/19 22:31:20 deraadt Exp $ */
+/* $OpenBSD: fstat.c,v 1.58 2007/04/07 23:20:19 tedu Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -37,7 +37,7 @@ static char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)fstat.c 8.1 (Berkeley) 6/6/93";*/
-static char *rcsid = "$OpenBSD: fstat.c,v 1.57 2006/06/19 22:31:20 deraadt Exp $";
+static char *rcsid = "$OpenBSD: fstat.c,v 1.58 2007/04/07 23:20:19 tedu Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -174,6 +174,7 @@ main(int argc, char *argv[])
int arg, ch, what;
char *memf, *nlistf;
char buf[_POSIX2_LINE_MAX];
+ const char *errstr;
int cnt;
gid_t gid;
@@ -201,12 +202,13 @@ main(int argc, char *argv[])
case 'p':
if (pflg++)
usage();
- if (!isdigit(*optarg)) {
- warnx( "-p requires a process id");
+ arg = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr != NULL) {
+ warnx("-p requires a process id, %s: %s",
+ errstr, optarg);
usage();
}
what = KERN_PROC_PID;
- arg = atoi(optarg);
break;
case 's':
sflg = 1;