diff options
author | sobomax <sobomax@FreeBSD.org> | 2010-03-25 02:14:04 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2010-03-25 02:14:04 +0000 |
commit | cf7d024643689761f71dcb3f7f3bcd87fbb36bdd (patch) | |
tree | d98c6b40f230adabef52d989117363487e3fc44f /contrib/tcp_wrappers | |
parent | c041d56cdf53775a30c5c413775aeef58662fab8 (diff) | |
download | FreeBSD-src-cf7d024643689761f71dcb3f7f3bcd87fbb36bdd.zip FreeBSD-src-cf7d024643689761f71dcb3f7f3bcd87fbb36bdd.tar.gz |
MFC: Allow comment in the middle of the line.
Diffstat (limited to 'contrib/tcp_wrappers')
-rw-r--r-- | contrib/tcp_wrappers/hosts_access.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/contrib/tcp_wrappers/hosts_access.c b/contrib/tcp_wrappers/hosts_access.c index 8220e64..03d305b 100644 --- a/contrib/tcp_wrappers/hosts_access.c +++ b/contrib/tcp_wrappers/hosts_access.c @@ -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"); |