diff options
-rw-r--r-- | misc.c | 16 | ||||
-rw-r--r-- | misc.h | 3 | ||||
-rw-r--r-- | readconf.c | 16 | ||||
-rw-r--r-- | servconf.c | 10 |
4 files changed, 27 insertions, 18 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: misc.c,v 1.119 2017/11/25 06:46:22 dtucker Exp $ */ | 1 | /* $OpenBSD: misc.c,v 1.120 2017/12/05 23:59:47 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2000 Markus Friedl. All rights reserved. |
4 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. | 4 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. |
@@ -2112,3 +2112,17 @@ bad: | |||
2112 | *errstr = errbuf; | 2112 | *errstr = errbuf; |
2113 | return 0; | 2113 | return 0; |
2114 | } | 2114 | } |
2115 | |||
2116 | const char * | ||
2117 | atoi_err(const char *nptr, int *val) | ||
2118 | { | ||
2119 | const char *errstr = NULL; | ||
2120 | long long num; | ||
2121 | |||
2122 | if (nptr == NULL || *nptr == '\0') | ||
2123 | return "missing"; | ||
2124 | num = strtonum(nptr, 0, INT_MAX, &errstr); | ||
2125 | if (errstr == NULL) | ||
2126 | *val = (int)num; | ||
2127 | return errstr; | ||
2128 | } | ||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: misc.h,v 1.68 2017/11/25 06:46:22 dtucker Exp $ */ | 1 | /* $OpenBSD: misc.h,v 1.69 2017/12/05 23:59:47 dtucker Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -74,6 +74,7 @@ double monotime_double(void); | |||
74 | void lowercase(char *s); | 74 | void lowercase(char *s); |
75 | int unix_listener(const char *, int, int); | 75 | int unix_listener(const char *, int, int); |
76 | int valid_domain(char *, int, const char **); | 76 | int valid_domain(char *, int, const char **); |
77 | const char *atoi_err(const char *, int *); | ||
77 | 78 | ||
78 | void sock_set_v6only(int); | 79 | void sock_set_v6only(int); |
79 | 80 | ||
diff --git a/readconf.c b/readconf.c index 63baa7d78..10b57bd45 100644 --- a/readconf.c +++ b/readconf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: readconf.c,v 1.280 2017/10/21 23:06:24 millert Exp $ */ | 1 | /* $OpenBSD: readconf.c,v 1.281 2017/12/05 23:59:47 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -817,6 +817,7 @@ process_config_line_depth(Options *options, struct passwd *pw, const char *host, | |||
817 | const struct multistate *multistate_ptr; | 817 | const struct multistate *multistate_ptr; |
818 | struct allowed_cname *cname; | 818 | struct allowed_cname *cname; |
819 | glob_t gl; | 819 | glob_t gl; |
820 | const char *errstr; | ||
820 | 821 | ||
821 | if (activep == NULL) { /* We are processing a command line directive */ | 822 | if (activep == NULL) { /* We are processing a command line directive */ |
822 | cmdline = 1; | 823 | cmdline = 1; |
@@ -1131,15 +1132,9 @@ parse_command: | |||
1131 | intptr = &options->port; | 1132 | intptr = &options->port; |
1132 | parse_int: | 1133 | parse_int: |
1133 | arg = strdelim(&s); | 1134 | arg = strdelim(&s); |
1134 | if (!arg || *arg == '\0') | 1135 | if ((errstr = atoi_err(arg, &value)) != NULL) |
1135 | fatal("%.200s line %d: Missing argument.", filename, linenum); | 1136 | fatal("%s line %d: integer value %s.", |
1136 | if (arg[0] < '0' || arg[0] > '9') | 1137 | filename, linenum, errstr); |
1137 | fatal("%.200s line %d: Bad number.", filename, linenum); | ||
1138 | |||
1139 | /* Octal, decimal, or hex format? */ | ||
1140 | value = strtol(arg, &endofnumber, 0); | ||
1141 | if (arg == endofnumber) | ||
1142 | fatal("%.200s line %d: Bad number.", filename, linenum); | ||
1143 | if (*activep && *intptr == -1) | 1138 | if (*activep && *intptr == -1) |
1144 | *intptr = value; | 1139 | *intptr = value; |
1145 | break; | 1140 | break; |
@@ -1534,7 +1529,6 @@ parse_keytypes: | |||
1534 | case oCanonicalDomains: | 1529 | case oCanonicalDomains: |
1535 | value = options->num_canonical_domains != 0; | 1530 | value = options->num_canonical_domains != 0; |
1536 | while ((arg = strdelim(&s)) != NULL && *arg != '\0') { | 1531 | while ((arg = strdelim(&s)) != NULL && *arg != '\0') { |
1537 | const char *errstr; | ||
1538 | if (!valid_domain(arg, 1, &errstr)) { | 1532 | if (!valid_domain(arg, 1, &errstr)) { |
1539 | fatal("%s line %d: %s", filename, linenum, | 1533 | fatal("%s line %d: %s", filename, linenum, |
1540 | errstr); | 1534 | errstr); |
diff --git a/servconf.c b/servconf.c index a9d727fdb..ff94bbd6b 100644 --- a/servconf.c +++ b/servconf.c | |||
@@ -1,5 +1,5 @@ | |||
1 | 1 | ||
2 | /* $OpenBSD: servconf.c,v 1.321 2017/12/05 23:56:07 dtucker Exp $ */ | 2 | /* $OpenBSD: servconf.c,v 1.322 2017/12/05 23:59:47 dtucker Exp $ */ |
3 | /* | 3 | /* |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
5 | * All rights reserved | 5 | * All rights reserved |
@@ -1152,6 +1152,7 @@ process_server_config_line(ServerOptions *options, char *line, | |||
1152 | size_t len; | 1152 | size_t len; |
1153 | long long val64; | 1153 | long long val64; |
1154 | const struct multistate *multistate_ptr; | 1154 | const struct multistate *multistate_ptr; |
1155 | const char *errstr; | ||
1155 | 1156 | ||
1156 | /* Strip trailing whitespace. Allow \f (form feed) at EOL only */ | 1157 | /* Strip trailing whitespace. Allow \f (form feed) at EOL only */ |
1157 | if ((len = strlen(line)) == 0) | 1158 | if ((len = strlen(line)) == 0) |
@@ -1441,10 +1442,9 @@ process_server_config_line(ServerOptions *options, char *line, | |||
1441 | intptr = &options->x11_display_offset; | 1442 | intptr = &options->x11_display_offset; |
1442 | parse_int: | 1443 | parse_int: |
1443 | arg = strdelim(&cp); | 1444 | arg = strdelim(&cp); |
1444 | if (!arg || *arg == '\0') | 1445 | if ((errstr = atoi_err(arg, &value)) != NULL) |
1445 | fatal("%s line %d: missing integer value.", | 1446 | fatal("%s line %d: integer value %s.", |
1446 | filename, linenum); | 1447 | filename, linenum, errstr); |
1447 | value = atoi(arg); | ||
1448 | if (*activep && *intptr == -1) | 1448 | if (*activep && *intptr == -1) |
1449 | *intptr = value; | 1449 | *intptr = value; |
1450 | break; | 1450 | break; |