bin/163487: syslog.conf filtering syntax broken in 9.0-RC3 (was
working in 8.2)
Mark Johnston
markjdb at gmail.com
Thu Jun 7 04:40:12 UTC 2012
The following reply was made to PR bin/163487; it has been noted by GNATS.
From: Mark Johnston <markjdb at gmail.com>
To: bug-followup at FreeBSD.org, root at claimlynx.com
Cc:
Subject: Re: bin/163487: syslog.conf filtering syntax broken in 9.0-RC3 (was
working in 8.2)
Date: Thu, 7 Jun 2012 00:33:16 -0400
--tThc/1wpZn/ma/RB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
I've attached a small patch which fixes the issue described above.
Basically, rather than calling trimdomain(3) on the entire host filter
string (which won't do anything if the filter contains multiple hosts),
this change has syslogd call trimdomain(3) on each host and then copy it
to f->f_host.
Would you be able to test this?
Thanks,
-Mark
--tThc/1wpZn/ma/RB
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="syslogd_domain_trimming.patch.txt"
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index d1c9fd1..75912ec 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1775,7 +1775,7 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host)
struct addrinfo hints, *res;
int error, i, pri, syncfile;
const char *p, *q;
- char *bp;
+ char *bp, *currhost, *nexthost, *hostoff;
char buf[MAXLINE], ebuf[100];
dprintf("cfline(\"%s\", f, \"%s\", \"%s\")\n", line, prog, host);
@@ -1793,15 +1793,25 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host)
if (host) {
int hl;
- f->f_host = strdup(host);
+ hl = strlen(host);
+ f->f_host = malloc(hl);
if (f->f_host == NULL) {
- logerror("strdup");
+ logerror("malloc");
exit(1);
}
- hl = strlen(f->f_host);
- if (hl > 0 && f->f_host[hl-1] == '.')
- f->f_host[--hl] = '\0';
- trimdomain(f->f_host, hl);
+
+ nexthost = (char *)host;
+ hostoff = f->f_host;
+ while ((currhost = strsep(&nexthost, ",")) != NULL) {
+ hl = strlen(currhost);
+ if (currhost[hl - 1] == '.')
+ currhost[hl - 1] = '\0';
+
+ trimdomain(currhost, MAXHOSTNAMELEN);
+ hostoff += strlcpy(hostoff, currhost, hl + 1);
+ if (nexthost != NULL)
+ *hostoff++ = ',';
+ }
}
/* save program name if any */
--tThc/1wpZn/ma/RB--
More information about the freebsd-bugs
mailing list