diff options
Diffstat (limited to 'readconf.c')
-rw-r--r-- | readconf.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/readconf.c b/readconf.c index 42a2961fa..db7d0bbbf 100644 --- a/readconf.c +++ b/readconf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: readconf.c,v 1.232 2015/02/16 22:13:32 djm Exp $ */ | 1 | /* $OpenBSD: readconf.c,v 1.237 2015/06/26 05:13:20 djm 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 |
@@ -295,7 +295,7 @@ add_local_forward(Options *options, const struct Forward *newfwd) | |||
295 | newfwd->listen_path == NULL) | 295 | newfwd->listen_path == NULL) |
296 | fatal("Privileged ports can only be forwarded by root."); | 296 | fatal("Privileged ports can only be forwarded by root."); |
297 | #endif | 297 | #endif |
298 | options->local_forwards = xrealloc(options->local_forwards, | 298 | options->local_forwards = xreallocarray(options->local_forwards, |
299 | options->num_local_forwards + 1, | 299 | options->num_local_forwards + 1, |
300 | sizeof(*options->local_forwards)); | 300 | sizeof(*options->local_forwards)); |
301 | fwd = &options->local_forwards[options->num_local_forwards++]; | 301 | fwd = &options->local_forwards[options->num_local_forwards++]; |
@@ -318,7 +318,7 @@ add_remote_forward(Options *options, const struct Forward *newfwd) | |||
318 | { | 318 | { |
319 | struct Forward *fwd; | 319 | struct Forward *fwd; |
320 | 320 | ||
321 | options->remote_forwards = xrealloc(options->remote_forwards, | 321 | options->remote_forwards = xreallocarray(options->remote_forwards, |
322 | options->num_remote_forwards + 1, | 322 | options->num_remote_forwards + 1, |
323 | sizeof(*options->remote_forwards)); | 323 | sizeof(*options->remote_forwards)); |
324 | fwd = &options->remote_forwards[options->num_remote_forwards++]; | 324 | fwd = &options->remote_forwards[options->num_remote_forwards++]; |
@@ -492,7 +492,6 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw, | |||
492 | char *arg, *oattrib, *attrib, *cmd, *cp = *condition, *host, *criteria; | 492 | char *arg, *oattrib, *attrib, *cmd, *cp = *condition, *host, *criteria; |
493 | const char *ruser; | 493 | const char *ruser; |
494 | int r, port, this_result, result = 1, attributes = 0, negate; | 494 | int r, port, this_result, result = 1, attributes = 0, negate; |
495 | size_t len; | ||
496 | char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; | 495 | char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; |
497 | 496 | ||
498 | /* | 497 | /* |
@@ -545,25 +544,24 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw, | |||
545 | result = -1; | 544 | result = -1; |
546 | goto out; | 545 | goto out; |
547 | } | 546 | } |
548 | len = strlen(arg); | ||
549 | if (strcasecmp(attrib, "host") == 0) { | 547 | if (strcasecmp(attrib, "host") == 0) { |
550 | criteria = xstrdup(host); | 548 | criteria = xstrdup(host); |
551 | r = match_hostname(host, arg, len) == 1; | 549 | r = match_hostname(host, arg) == 1; |
552 | if (r == (negate ? 1 : 0)) | 550 | if (r == (negate ? 1 : 0)) |
553 | this_result = result = 0; | 551 | this_result = result = 0; |
554 | } else if (strcasecmp(attrib, "originalhost") == 0) { | 552 | } else if (strcasecmp(attrib, "originalhost") == 0) { |
555 | criteria = xstrdup(original_host); | 553 | criteria = xstrdup(original_host); |
556 | r = match_hostname(original_host, arg, len) == 1; | 554 | r = match_hostname(original_host, arg) == 1; |
557 | if (r == (negate ? 1 : 0)) | 555 | if (r == (negate ? 1 : 0)) |
558 | this_result = result = 0; | 556 | this_result = result = 0; |
559 | } else if (strcasecmp(attrib, "user") == 0) { | 557 | } else if (strcasecmp(attrib, "user") == 0) { |
560 | criteria = xstrdup(ruser); | 558 | criteria = xstrdup(ruser); |
561 | r = match_pattern_list(ruser, arg, len, 0) == 1; | 559 | r = match_pattern_list(ruser, arg, 0) == 1; |
562 | if (r == (negate ? 1 : 0)) | 560 | if (r == (negate ? 1 : 0)) |
563 | this_result = result = 0; | 561 | this_result = result = 0; |
564 | } else if (strcasecmp(attrib, "localuser") == 0) { | 562 | } else if (strcasecmp(attrib, "localuser") == 0) { |
565 | criteria = xstrdup(pw->pw_name); | 563 | criteria = xstrdup(pw->pw_name); |
566 | r = match_pattern_list(pw->pw_name, arg, len, 0) == 1; | 564 | r = match_pattern_list(pw->pw_name, arg, 0) == 1; |
567 | if (r == (negate ? 1 : 0)) | 565 | if (r == (negate ? 1 : 0)) |
568 | this_result = result = 0; | 566 | this_result = result = 0; |
569 | } else if (strcasecmp(attrib, "exec") == 0) { | 567 | } else if (strcasecmp(attrib, "exec") == 0) { |
@@ -665,8 +663,8 @@ parse_token(const char *cp, const char *filename, int linenum, | |||
665 | for (i = 0; keywords[i].name; i++) | 663 | for (i = 0; keywords[i].name; i++) |
666 | if (strcmp(cp, keywords[i].name) == 0) | 664 | if (strcmp(cp, keywords[i].name) == 0) |
667 | return keywords[i].opcode; | 665 | return keywords[i].opcode; |
668 | if (ignored_unknown != NULL && match_pattern_list(cp, ignored_unknown, | 666 | if (ignored_unknown != NULL && |
669 | strlen(ignored_unknown), 1) == 1) | 667 | match_pattern_list(cp, ignored_unknown, 1) == 1) |
670 | return oIgnoredUnknownOption; | 668 | return oIgnoredUnknownOption; |
671 | error("%s: line %d: Bad configuration option: %s", | 669 | error("%s: line %d: Bad configuration option: %s", |
672 | filename, linenum, cp); | 670 | filename, linenum, cp); |
@@ -763,7 +761,9 @@ process_config_line(Options *options, struct passwd *pw, const char *host, | |||
763 | } | 761 | } |
764 | 762 | ||
765 | /* Strip trailing whitespace */ | 763 | /* Strip trailing whitespace */ |
766 | for (len = strlen(line) - 1; len > 0; len--) { | 764 | if ((len = strlen(line)) == 0) |
765 | return 0; | ||
766 | for (len--; len > 0; len--) { | ||
767 | if (strchr(WHITESPACE, line[len]) == NULL) | 767 | if (strchr(WHITESPACE, line[len]) == NULL) |
768 | break; | 768 | break; |
769 | line[len] = '\0'; | 769 | line[len] = '\0'; |
@@ -1236,13 +1236,13 @@ parse_int: | |||
1236 | arg = strdelim(&s); | 1236 | arg = strdelim(&s); |
1237 | if (!arg || *arg == '\0') | 1237 | if (!arg || *arg == '\0') |
1238 | fatal("%.200s line %d: Missing argument.", filename, linenum); | 1238 | fatal("%.200s line %d: Missing argument.", filename, linenum); |
1239 | if (arg[0] == '^' && arg[2] == 0 && | 1239 | if (strcmp(arg, "none") == 0) |
1240 | value = SSH_ESCAPECHAR_NONE; | ||
1241 | else if (arg[1] == '\0') | ||
1242 | value = (u_char) arg[0]; | ||
1243 | else if (arg[0] == '^' && arg[2] == 0 && | ||
1240 | (u_char) arg[1] >= 64 && (u_char) arg[1] < 128) | 1244 | (u_char) arg[1] >= 64 && (u_char) arg[1] < 128) |
1241 | value = (u_char) arg[1] & 31; | 1245 | value = (u_char) arg[1] & 31; |
1242 | else if (strlen(arg) == 1) | ||
1243 | value = (u_char) arg[0]; | ||
1244 | else if (strcmp(arg, "none") == 0) | ||
1245 | value = SSH_ESCAPECHAR_NONE; | ||
1246 | else { | 1246 | else { |
1247 | fatal("%.200s line %d: Bad escape character.", | 1247 | fatal("%.200s line %d: Bad escape character.", |
1248 | filename, linenum); | 1248 | filename, linenum); |
@@ -1927,7 +1927,8 @@ parse_fwd_field(char **p, struct fwdarg *fwd) | |||
1927 | switch (*cp) { | 1927 | switch (*cp) { |
1928 | case '\\': | 1928 | case '\\': |
1929 | memmove(cp, cp + 1, strlen(cp + 1) + 1); | 1929 | memmove(cp, cp + 1, strlen(cp + 1) + 1); |
1930 | cp++; | 1930 | if (*cp == '\0') |
1931 | return -1; | ||
1931 | break; | 1932 | break; |
1932 | case '/': | 1933 | case '/': |
1933 | ispath = 1; | 1934 | ispath = 1; |