summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/readconf.c b/readconf.c
index 66a62f269..f0769b574 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
@@ -312,7 +312,7 @@ add_local_forward(Options *options, const struct Forward *newfwd)
312 newfwd->listen_path == NULL) 312 newfwd->listen_path == NULL)
313 fatal("Privileged ports can only be forwarded by root."); 313 fatal("Privileged ports can only be forwarded by root.");
314#endif 314#endif
315 options->local_forwards = xrealloc(options->local_forwards, 315 options->local_forwards = xreallocarray(options->local_forwards,
316 options->num_local_forwards + 1, 316 options->num_local_forwards + 1,
317 sizeof(*options->local_forwards)); 317 sizeof(*options->local_forwards));
318 fwd = &options->local_forwards[options->num_local_forwards++]; 318 fwd = &options->local_forwards[options->num_local_forwards++];
@@ -335,7 +335,7 @@ add_remote_forward(Options *options, const struct Forward *newfwd)
335{ 335{
336 struct Forward *fwd; 336 struct Forward *fwd;
337 337
338 options->remote_forwards = xrealloc(options->remote_forwards, 338 options->remote_forwards = xreallocarray(options->remote_forwards,
339 options->num_remote_forwards + 1, 339 options->num_remote_forwards + 1,
340 sizeof(*options->remote_forwards)); 340 sizeof(*options->remote_forwards));
341 fwd = &options->remote_forwards[options->num_remote_forwards++]; 341 fwd = &options->remote_forwards[options->num_remote_forwards++];
@@ -509,7 +509,6 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw,
509 char *arg, *oattrib, *attrib, *cmd, *cp = *condition, *host, *criteria; 509 char *arg, *oattrib, *attrib, *cmd, *cp = *condition, *host, *criteria;
510 const char *ruser; 510 const char *ruser;
511 int r, port, this_result, result = 1, attributes = 0, negate; 511 int r, port, this_result, result = 1, attributes = 0, negate;
512 size_t len;
513 char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; 512 char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV];
514 513
515 /* 514 /*
@@ -562,25 +561,24 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw,
562 result = -1; 561 result = -1;
563 goto out; 562 goto out;
564 } 563 }
565 len = strlen(arg);
566 if (strcasecmp(attrib, "host") == 0) { 564 if (strcasecmp(attrib, "host") == 0) {
567 criteria = xstrdup(host); 565 criteria = xstrdup(host);
568 r = match_hostname(host, arg, len) == 1; 566 r = match_hostname(host, arg) == 1;
569 if (r == (negate ? 1 : 0)) 567 if (r == (negate ? 1 : 0))
570 this_result = result = 0; 568 this_result = result = 0;
571 } else if (strcasecmp(attrib, "originalhost") == 0) { 569 } else if (strcasecmp(attrib, "originalhost") == 0) {
572 criteria = xstrdup(original_host); 570 criteria = xstrdup(original_host);
573 r = match_hostname(original_host, arg, len) == 1; 571 r = match_hostname(original_host, arg) == 1;
574 if (r == (negate ? 1 : 0)) 572 if (r == (negate ? 1 : 0))
575 this_result = result = 0; 573 this_result = result = 0;
576 } else if (strcasecmp(attrib, "user") == 0) { 574 } else if (strcasecmp(attrib, "user") == 0) {
577 criteria = xstrdup(ruser); 575 criteria = xstrdup(ruser);
578 r = match_pattern_list(ruser, arg, len, 0) == 1; 576 r = match_pattern_list(ruser, arg, 0) == 1;
579 if (r == (negate ? 1 : 0)) 577 if (r == (negate ? 1 : 0))
580 this_result = result = 0; 578 this_result = result = 0;
581 } else if (strcasecmp(attrib, "localuser") == 0) { 579 } else if (strcasecmp(attrib, "localuser") == 0) {
582 criteria = xstrdup(pw->pw_name); 580 criteria = xstrdup(pw->pw_name);
583 r = match_pattern_list(pw->pw_name, arg, len, 0) == 1; 581 r = match_pattern_list(pw->pw_name, arg, 0) == 1;
584 if (r == (negate ? 1 : 0)) 582 if (r == (negate ? 1 : 0))
585 this_result = result = 0; 583 this_result = result = 0;
586 } else if (strcasecmp(attrib, "exec") == 0) { 584 } else if (strcasecmp(attrib, "exec") == 0) {
@@ -682,8 +680,8 @@ parse_token(const char *cp, const char *filename, int linenum,
682 for (i = 0; keywords[i].name; i++) 680 for (i = 0; keywords[i].name; i++)
683 if (strcmp(cp, keywords[i].name) == 0) 681 if (strcmp(cp, keywords[i].name) == 0)
684 return keywords[i].opcode; 682 return keywords[i].opcode;
685 if (ignored_unknown != NULL && match_pattern_list(cp, ignored_unknown, 683 if (ignored_unknown != NULL &&
686 strlen(ignored_unknown), 1) == 1) 684 match_pattern_list(cp, ignored_unknown, 1) == 1)
687 return oIgnoredUnknownOption; 685 return oIgnoredUnknownOption;
688 error("%s: line %d: Bad configuration option: %s", 686 error("%s: line %d: Bad configuration option: %s",
689 filename, linenum, cp); 687 filename, linenum, cp);
@@ -780,7 +778,9 @@ process_config_line(Options *options, struct passwd *pw, const char *host,
780 } 778 }
781 779
782 /* Strip trailing whitespace */ 780 /* Strip trailing whitespace */
783 for (len = strlen(line) - 1; len > 0; len--) { 781 if ((len = strlen(line)) == 0)
782 return 0;
783 for (len--; len > 0; len--) {
784 if (strchr(WHITESPACE, line[len]) == NULL) 784 if (strchr(WHITESPACE, line[len]) == NULL)
785 break; 785 break;
786 line[len] = '\0'; 786 line[len] = '\0';
@@ -1273,13 +1273,13 @@ parse_int:
1273 arg = strdelim(&s); 1273 arg = strdelim(&s);
1274 if (!arg || *arg == '\0') 1274 if (!arg || *arg == '\0')
1275 fatal("%.200s line %d: Missing argument.", filename, linenum); 1275 fatal("%.200s line %d: Missing argument.", filename, linenum);
1276 if (arg[0] == '^' && arg[2] == 0 && 1276 if (strcmp(arg, "none") == 0)
1277 value = SSH_ESCAPECHAR_NONE;
1278 else if (arg[1] == '\0')
1279 value = (u_char) arg[0];
1280 else if (arg[0] == '^' && arg[2] == 0 &&
1277 (u_char) arg[1] >= 64 && (u_char) arg[1] < 128) 1281 (u_char) arg[1] >= 64 && (u_char) arg[1] < 128)
1278 value = (u_char) arg[1] & 31; 1282 value = (u_char) arg[1] & 31;
1279 else if (strlen(arg) == 1)
1280 value = (u_char) arg[0];
1281 else if (strcmp(arg, "none") == 0)
1282 value = SSH_ESCAPECHAR_NONE;
1283 else { 1283 else {
1284 fatal("%.200s line %d: Bad escape character.", 1284 fatal("%.200s line %d: Bad escape character.",
1285 filename, linenum); 1285 filename, linenum);
@@ -1981,7 +1981,8 @@ parse_fwd_field(char **p, struct fwdarg *fwd)
1981 switch (*cp) { 1981 switch (*cp) {
1982 case '\\': 1982 case '\\':
1983 memmove(cp, cp + 1, strlen(cp + 1) + 1); 1983 memmove(cp, cp + 1, strlen(cp + 1) + 1);
1984 cp++; 1984 if (*cp == '\0')
1985 return -1;
1985 break; 1986 break;
1986 case '/': 1987 case '/':
1987 ispath = 1; 1988 ispath = 1;