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/rpc.lockd | |
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/rpc.lockd')
-rw-r--r-- | usr.sbin/rpc.lockd/lockd.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.sbin/rpc.lockd/lockd.c b/usr.sbin/rpc.lockd/lockd.c index f0c8fbd943f..4b7397e3fd5 100644 --- a/usr.sbin/rpc.lockd/lockd.c +++ b/usr.sbin/rpc.lockd/lockd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lockd.c,v 1.13 2015/01/16 06:40:20 deraadt Exp $ */ +/* $OpenBSD: lockd.c,v 1.14 2015/04/18 18:28:38 deraadt Exp $ */ /* * Copyright (c) 1995 @@ -46,6 +46,7 @@ #include <err.h> #include <errno.h> #include <signal.h> +#include <limits.h> #include <string.h> #include <unistd.h> #include <netdb.h> @@ -68,6 +69,7 @@ int main(int argc, char *argv[]) { SVCXPRT *transp; + const char *errstr; int ch; struct sigaction sigchild, sigalarm; int grace_period = 30; @@ -75,15 +77,15 @@ main(int argc, char *argv[]) while ((ch = getopt(argc, argv, "d:g:")) != (-1)) { switch (ch) { case 'd': - debug_level = atoi(optarg); - if (!debug_level) { + debug_level = strtonum(optarg, 1, INT_MAX, &errstr); + if (errstr) { usage(); /* NOTREACHED */ } break; case 'g': - grace_period = atoi(optarg); - if (!grace_period) { + grace_period = strtonum(optarg, 1, INT_MAX, &errstr); + if (errstr) { usage(); /* NOTREACHED */ } |