=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/readconf.c,v retrieving revision 1.342 retrieving revision 1.343 diff -u -r1.342 -r1.343 --- src/usr.bin/ssh/readconf.c 2020/11/15 22:34:58 1.342 +++ src/usr.bin/ssh/readconf.c 2020/11/30 05:36:39 1.343 @@ -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 * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -1885,7 +1885,7 @@ 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 @@ 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)