diff options
author | 2020-11-30 05:36:39 +0000 | |
---|---|---|
committer | 2020-11-30 05:36:39 +0000 | |
commit | dd1a025b401258171fc472c3af78ccb3b4b3bf6d (patch) | |
tree | dfff954974f48646513c6943fb1699f9cf81bc48 | |
parent | sync (diff) | |
download | wireguard-openbsd-dd1a025b401258171fc472c3af78ccb3b4b3bf6d.tar.xz wireguard-openbsd-dd1a025b401258171fc472c3af78ccb3b4b3bf6d.zip |
Ignore comments at the end of config lines in ssh_config, similar to what
we already do for sshd_config. bz#2320, with & ok djm@
-rw-r--r-- | usr.bin/ssh/readconf.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/usr.bin/ssh/readconf.c b/usr.bin/ssh/readconf.c index 189dcd5dbcf..cffbd0db2fa 100644 --- a/usr.bin/ssh/readconf.c +++ b/usr.bin/ssh/readconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readconf.c,v 1.342 2020/11/15 22:34:58 djm Exp $ */ +/* $OpenBSD: readconf.c,v 1.343 2020/11/30 05:36:39 dtucker Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -1885,7 +1885,7 @@ read_config_file_depth(const char *filename, struct passwd *pw, int flags, int *activep, int *want_final_pass, int depth) { FILE *f; - char *line = NULL; + char *cp, *line = NULL; size_t linesize = 0; int linenum; int bad_options = 0; @@ -1916,6 +1916,13 @@ read_config_file_depth(const char *filename, struct passwd *pw, while (getline(&line, &linesize, f) != -1) { /* Update line number counter. */ linenum++; + /* + * Trim out comments and strip whitespace. + * NB - preserve newlines, they are needed to reproduce + * line numbers later for error messages. + */ + if ((cp = strchr(line, '#')) != NULL) + *cp = '\0'; if (process_config_line_depth(options, pw, host, original_host, line, filename, linenum, activep, flags, want_final_pass, depth) != 0) |