diff options
author | deraadt <deraadt@openbsd.org> | 2015-04-18 18:28:36 +0000 |
---|---|---|
committer | deraadt <deraadt@openbsd.org> | 2015-04-18 18:28:36 +0000 |
commit | a47b6461a15f74beac188483616126ed5e987f93 (patch) | |
tree | 4453af12f02f369f89c8895bcfef1820fdb8576d /usr.sbin/ndp | |
parent | Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(), (diff) | |
download | wireguard-openbsd-a47b6461a15f74beac188483616126ed5e987f93.tar.xz wireguard-openbsd-a47b6461a15f74beac188483616126ed5e987f93.zip |
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*/ } |