From owner-freebsd-bugs@FreeBSD.ORG Thu Jun 7 04:40:12 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 78B241065675 for ; Thu, 7 Jun 2012 04:40:12 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 4AA448FC12 for ; Thu, 7 Jun 2012 04:40:12 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q574eCTk022275 for ; Thu, 7 Jun 2012 04:40:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q574eCfE022274; Thu, 7 Jun 2012 04:40:12 GMT (envelope-from gnats) Date: Thu, 7 Jun 2012 04:40:12 GMT Message-Id: <201206070440.q574eCfE022274@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Mark Johnston Cc: Subject: Re: bin/163487: syslog.conf filtering syntax broken in 9.0-RC3 (was working in 8.2) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Mark Johnston List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jun 2012 04:40:12 -0000 The following reply was made to PR bin/163487; it has been noted by GNATS. From: Mark Johnston To: bug-followup@FreeBSD.org, root@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--