summaryrefslogtreecommitdiff
path: root/sbin/quotacheck/quotacheck.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-04-18 18:28:39 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-04-18 18:28:39 +0000
commit82e40d211902d486d2871a1bc691d1768927efd5 (patch)
tree73caeece4da00dad32b1e62383474772aae90893 /sbin/quotacheck/quotacheck.c
parenta15dfcc7862a97d34cf8fed2bb1292c14721e771 (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 'sbin/quotacheck/quotacheck.c')
-rw-r--r--sbin/quotacheck/quotacheck.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sbin/quotacheck/quotacheck.c b/sbin/quotacheck/quotacheck.c
index 8b1966287fb..bbf4e0fbe85 100644
--- a/sbin/quotacheck/quotacheck.c
+++ b/sbin/quotacheck/quotacheck.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: quotacheck.c,v 1.37 2015/02/07 02:09:14 deraadt Exp $ */
+/* $OpenBSD: quotacheck.c,v 1.38 2015/04/18 18:28:37 deraadt Exp $ */
/* $NetBSD: quotacheck.c,v 1.12 1996/03/30 22:34:25 mark Exp $ */
/*
@@ -136,6 +136,7 @@ main(int argc, char *argv[])
struct quotaname *auxdata;
int i, argnum, maxrun, errs, ch;
u_int64_t done = 0; /* XXX supports maximum 64 filesystems */
+ const char *errstr;
char *name;
errs = maxrun = 0;
@@ -151,7 +152,9 @@ main(int argc, char *argv[])
gflag = 1;
break;
case 'l':
- maxrun = atoi(optarg);
+ maxrun = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-l %s: %s", optarg, errstr);
break;
case 'u':
uflag = 1;