diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-04-18 18:28:39 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-04-18 18:28:39 +0000 |
commit | 82e40d211902d486d2871a1bc691d1768927efd5 (patch) | |
tree | 73caeece4da00dad32b1e62383474772aae90893 /usr.sbin/ndp | |
parent | a15dfcc7862a97d34cf8fed2bb1292c14721e771 (diff) |
Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way.
Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert
Diffstat (limited to 'usr.sbin/ndp')
-rw-r--r-- | usr.sbin/ndp/ndp.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c index bd8b76f8505..ce75ef718a0 100644 --- a/usr.sbin/ndp/ndp.c +++ b/usr.sbin/ndp/ndp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ndp.c,v 1.59 2015/01/16 06:40:18 deraadt Exp $ */ +/* $OpenBSD: ndp.c,v 1.60 2015/04/18 18:28:38 deraadt Exp $ */ /* $KAME: ndp.c,v 1.101 2002/07/17 08:46:33 itojun Exp $ */ /* @@ -102,6 +102,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <err.h> #include "gmt2local.h" @@ -202,8 +203,8 @@ main(int argc, char *argv[]) /*NOTREACHED*/ } mode = 'a'; - repeat = atoi(optarg); - if (repeat < 0) { + repeat = strtonum(optarg, 1, INT_MAX, &errstr); + if (errstr) { usage(); /*NOTREACHED*/ } |