[openssh-commits] [openssh] 01/07: upstream: Ignore comments at the end of config lines in ssh_config,

git+noreply at mindrot.org git+noreply at mindrot.org
Fri Dec 4 13:43:54 AEDT 2020


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 2bcbf679de838bb77a8bd7fa18e100df471a679c
Author: dtucker at openbsd.org <dtucker at openbsd.org>
Date:   Mon Nov 30 05:36:39 2020 +0000

    upstream: 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@
    
    OpenBSD-Commit-ID: bdbf9fc5bc72b1a14266f5f61723ed57307a6db4
---
 readconf.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/readconf.c b/readconf.c
index 09b5e086..d60eeacf 100644
--- a/readconf.c
+++ b/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 at cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -1899,7 +1899,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;
@@ -1930,6 +1930,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)

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list