Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Jan 2010 10:54:15 +0000 (UTC)
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r201782 - head/contrib/tcp_wrappers
Message-ID:  <201001081054.o08AsFVA050831@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sobomax
Date: Fri Jan  8 10:54:15 2010
New Revision: 201782
URL: http://svn.freebsd.org/changeset/base/201782

Log:
  Allow comment (#) to be placed anywhere in the line, not only at the
  beginning, so it's consistent with other configuration files.
  
  MFC after:	3 weeks

Modified:
  head/contrib/tcp_wrappers/hosts_access.c

Modified: head/contrib/tcp_wrappers/hosts_access.c
==============================================================================
--- head/contrib/tcp_wrappers/hosts_access.c	Fri Jan  8 10:32:27 2010	(r201781)
+++ head/contrib/tcp_wrappers/hosts_access.c	Fri Jan  8 10:54:15 2010	(r201782)
@@ -148,6 +148,7 @@ struct request_info *request;
     char   *sh_cmd;			/* becomes optional shell command */
     int     match = NO;
     struct tcpd_context saved_context;
+    char   *cp;
 
     saved_context = tcpd_context;		/* stupid compilers */
 
@@ -164,7 +165,16 @@ struct request_info *request;
 		tcpd_warn("missing newline or line too long");
 		continue;
 	    }
-	    if (sv_list[0] == '#' || sv_list[strspn(sv_list, " \t\r\n")] == 0)
+	    /* Ignore anything after unescaped # character */
+	    for (cp = strchr(sv_list, '#'); cp != NULL;) {
+		if (cp > sv_list && cp[-1] == '\\') {
+		    cp = strchr(cp + 1, '#');
+		    continue;
+		}
+		*cp = '\0';
+		break;
+	    }
+	    if (sv_list[strspn(sv_list, " \t\r\n")] == 0)
 		continue;
 	    if ((cl_list = split_at(sv_list, ':')) == 0) {
 		tcpd_warn("missing \":\" separator");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001081054.o08AsFVA050831>