summaryrefslogtreecommitdiffstats
path: root/sbin/swapctl
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2015-04-18 18:28:36 +0000
committerderaadt <deraadt@openbsd.org>2015-04-18 18:28:36 +0000
commita47b6461a15f74beac188483616126ed5e987f93 (patch)
tree4453af12f02f369f89c8895bcfef1820fdb8576d /sbin/swapctl
parentDelete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(), (diff)
downloadwireguard-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 'sbin/swapctl')
-rw-r--r--sbin/swapctl/swapctl.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sbin/swapctl/swapctl.c b/sbin/swapctl/swapctl.c
index 0b561f2b483..94f749850bb 100644
--- a/sbin/swapctl/swapctl.c
+++ b/sbin/swapctl/swapctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: swapctl.c,v 1.19 2015/01/16 06:40:01 deraadt Exp $ */
+/* $OpenBSD: swapctl.c,v 1.20 2015/04/18 18:28:37 deraadt Exp $ */
/* $NetBSD: swapctl.c,v 1.9 1998/07/26 20:23:15 mycroft Exp $ */
/*
@@ -58,6 +58,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
+#include <limits.h>
#include <string.h>
#include <fstab.h>
#include <util.h>
@@ -116,6 +117,7 @@ extern char *__progname; /* from crt0.o */
int
main(int argc, char *argv[])
{
+ const char *errstr;
int c;
if (strcmp(__progname, "swapon") == 0)
@@ -149,8 +151,9 @@ main(int argc, char *argv[])
case 'p':
pflag = 1;
- /* XXX strtol() */
- pri = atoi(optarg);
+ pri = strtonum(optarg, 0, INT_MAX, &errstr);
+ if (errstr)
+ errx(1, "-p %s: %s", errstr, optarg);
break;
case 's':