summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobhe <tobhe@openbsd.org>2020-12-17 20:43:07 +0000
committertobhe <tobhe@openbsd.org>2020-12-17 20:43:07 +0000
commit277a74a3b6867acb68b3c368c3ea1961997e5dff (patch)
treee5bd0ff138f7c37882e0b5b55e58d60842b3336c
parentSort command line options. (diff)
downloadwireguard-openbsd-277a74a3b6867acb68b3c368c3ea1961997e5dff.tar.xz
wireguard-openbsd-277a74a3b6867acb68b3c368c3ea1961997e5dff.zip
Use strtonum() instead of atoi() to parse port option.
-rw-r--r--sbin/iked/iked.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sbin/iked/iked.c b/sbin/iked/iked.c
index fe7dac9a92f..202879bc58c 100644
--- a/sbin/iked/iked.c
+++ b/sbin/iked/iked.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iked.c,v 1.51 2020/12/17 20:32:21 tobhe Exp $ */
+/* $OpenBSD: iked.c,v 1.52 2020/12/17 20:43:07 tobhe Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
@@ -71,6 +71,7 @@ main(int argc, char *argv[])
in_port_t port = IKED_NATT_PORT;
const char *conffile = IKED_CONFIG;
const char *sock = IKED_SOCKET;
+ const char *errstr;
struct iked *env = NULL;
struct privsep *ps;
@@ -100,7 +101,9 @@ main(int argc, char *argv[])
case 'p':
if (natt_mode == NATT_DISABLE)
errx(1, "-T and -p are mutually exclusive");
- port = atoi(optarg);
+ port = strtonum(optarg, 1, UINT16_MAX, &errstr);
+ if (errstr != NULL)
+ errx(1, "port is %s: %s", errstr, optarg);
natt_mode = NATT_FORCE;
break;
case 'S':