summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/main.c
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2014-02-13 20:51:21 +0000
committertedu <tedu@openbsd.org>2014-02-13 20:51:21 +0000
commitb9c46042705df358b9a7ea17d3e0de1c18a901a7 (patch)
treed31b2e040d5e6e34bb17ef81e76f36a3dee6bf7d /usr.bin/netstat/main.c
parentuse strotonum (diff)
downloadwireguard-openbsd-b9c46042705df358b9a7ea17d3e0de1c18a901a7.tar.xz
wireguard-openbsd-b9c46042705df358b9a7ea17d3e0de1c18a901a7.zip
use strtonum. ok krw
Diffstat (limited to 'usr.bin/netstat/main.c')
-rw-r--r--usr.bin/netstat/main.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index 0df4b9a257a..765be267585 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.99 2014/01/10 04:54:35 guenther Exp $ */
+/* $OpenBSD: main.c,v 1.100 2014/02/13 20:51:21 tedu Exp $ */
/* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */
/*
@@ -182,6 +182,8 @@ main(int argc, char *argv[])
break;
case 'c':
repeatcount = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "count is %s", errstr);
break;
case 'd':
dflag = 1;
@@ -289,7 +291,9 @@ main(int argc, char *argv[])
interface = optarg;
break;
case 'w':
- interval = atoi(optarg);
+ interval = strtonum(optarg, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "interval is %s", errstr);
iflag = 1;
break;
case '?':
@@ -314,9 +318,9 @@ main(int argc, char *argv[])
#ifdef BACKWARD_COMPATIBILITY
if (*argv) {
if (isdigit((unsigned char)**argv)) {
- interval = atoi(*argv);
- if (interval <= 0)
- usage();
+ interval = strtonum(*argv, 1, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "interval is %s", errstr);
++argv;
iflag = 1;
}