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/sa | |
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/sa')
-rw-r--r-- | usr.sbin/sa/main.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.sbin/sa/main.c b/usr.sbin/sa/main.c index f7c0f1c4f15..f64f03c7265 100644 --- a/usr.sbin/sa/main.c +++ b/usr.sbin/sa/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.12 2013/11/24 01:06:19 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.13 2015/04/18 18:28:38 deraadt Exp $ */ /* * Copyright (c) 1994 Christopher G. Demetriou * All rights reserved. @@ -72,6 +72,7 @@ main(int argc, char **argv) { int ch; int error = 0; + const char *errstr; extern char *__progname; while ((ch = getopt(argc, argv, "abcdDfijkKlmnqrstuv:")) != -1) @@ -156,7 +157,10 @@ main(int argc, char **argv) case 'v': /* cull junk */ vflag = 1; - cutoff = atoi(optarg); + /* XXX cutoff could be converted to quad_t? */ + cutoff = strtonum(optarg, 1, INT_MAX, &errstr); + if (errstr) + errx(1, "-v $s: %s", optarg, errstr); break; case '?': default: |