summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/readconf.c
diff options
context:
space:
mode:
authordtucker <dtucker@openbsd.org>2017-12-05 23:59:47 +0000
committerdtucker <dtucker@openbsd.org>2017-12-05 23:59:47 +0000
commit25a0d84aa49a885d0da533e6b2641e05c65dfa48 (patch)
treee2083e39c63b968dbf5786d1393e2e066b72ac90 /usr.bin/ssh/readconf.c
parentAdd missing break for rdomain. Prevents spurious "Deprecated option" (diff)
downloadwireguard-openbsd-25a0d84aa49a885d0da533e6b2641e05c65dfa48.tar.xz
wireguard-openbsd-25a0d84aa49a885d0da533e6b2641e05c65dfa48.zip
Replace atoi and strtol conversions for integer arguments to config
keywords with a checking wrapper around strtonum. This will prevent and flag invalid and negative arguments to these keywords. ok djm@
Diffstat (limited to 'usr.bin/ssh/readconf.c')
-rw-r--r--usr.bin/ssh/readconf.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/usr.bin/ssh/readconf.c b/usr.bin/ssh/readconf.c
index e3a7e110d7a..59f0032c523 100644
--- a/usr.bin/ssh/readconf.c
+++ b/usr.bin/ssh/readconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readconf.c,v 1.280 2017/10/21 23:06:24 millert Exp $ */
+/* $OpenBSD: readconf.c,v 1.281 2017/12/05 23:59:47 dtucker Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -802,6 +802,7 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host,
const struct multistate *multistate_ptr;
struct allowed_cname *cname;
glob_t gl;
+ const char *errstr;
if (activep == NULL) { /* We are processing a command line directive */
cmdline = 1;
@@ -1116,15 +1117,9 @@ parse_command:
intptr = &options->port;
parse_int:
arg = strdelim(&s);
- if (!arg || *arg == '\0')
- fatal("%.200s line %d: Missing argument.", filename, linenum);
- if (arg[0] < '0' || arg[0] > '9')
- fatal("%.200s line %d: Bad number.", filename, linenum);
-
- /* Octal, decimal, or hex format? */
- value = strtol(arg, &endofnumber, 0);
- if (arg == endofnumber)
- fatal("%.200s line %d: Bad number.", filename, linenum);
+ if ((errstr = atoi_err(arg, &value)) != NULL)
+ fatal("%s line %d: integer value %s.",
+ filename, linenum, errstr);
if (*activep && *intptr == -1)
*intptr = value;
break;
@@ -1519,7 +1514,6 @@ parse_keytypes:
case oCanonicalDomains:
value = options->num_canonical_domains != 0;
while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
- const char *errstr;
if (!valid_domain(arg, 1, &errstr)) {
fatal("%s line %d: %s", filename, linenum,
errstr);