From owner-freebsd-bugs@FreeBSD.ORG Mon Nov 26 07:20:01 2012 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9C764F72 for ; Mon, 26 Nov 2012 07:20:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 7336B8FC0C for ; Mon, 26 Nov 2012 07:20:01 +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 qAQ7K08v004222 for ; Mon, 26 Nov 2012 07:20:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id qAQ7K0DO004221; Mon, 26 Nov 2012 07:20:00 GMT (envelope-from gnats) Resent-Date: Mon, 26 Nov 2012 07:20:00 GMT Resent-Message-Id: <201211260720.qAQ7K0DO004221@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Garrett Cooper Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9B452F60 for ; Mon, 26 Nov 2012 07:18:00 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 834CC8FC12 for ; Mon, 26 Nov 2012 07:18:00 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id qAQ7I0gK061630 for ; Mon, 26 Nov 2012 07:18:00 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id qAQ7I00x061629; Mon, 26 Nov 2012 07:18:00 GMT (envelope-from nobody) Message-Id: <201211260718.qAQ7I00x061629@red.freebsd.org> Date: Mon, 26 Nov 2012 07:18:00 GMT From: Garrett Cooper To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: bin/173930: [patch] syslogd(8) error condition "touchups" X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Nov 2012 07:20:01 -0000 >Number: 173930 >Category: bin >Synopsis: [patch] syslogd(8) error condition "touchups" >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Nov 26 07:20:00 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Garrett Cooper >Release: 9-STABLE >Organization: EMC Isilon >Environment: FreeBSD bayonetta.local 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0 r240836M: Sat Sep 22 12:30:11 PDT 2012 gcooper@bayonetta.local:/usr/obj/store/freebsd/stable/9/sys/BAYONETTA amd64 >Description: A couple things: 1. Decoding priorities in cfline incorrectly emits errno information if decoding syslog.conf entries fails. 2. syslogd decodes IPv6 addresses, regardless of whether or not syslogd was compiled with INET6 support. 3. If binding the syslog socket fails, it could mangle the errno value, obfuscating the error returned from bind(2). >How-To-Repeat: >Fix: Patch attached with submission follows: Index: usr.sbin/syslogd/syslogd.c =================================================================== --- usr.sbin/syslogd/syslogd.c (revision 242903) +++ usr.sbin/syslogd/syslogd.c (working copy) @@ -1873,6 +1873,7 @@ pri = decode(buf, prioritynames); if (pri < 0) { + errno = 0; (void)snprintf(ebuf, sizeof ebuf, "unknown priority name \"%s\"", buf); logerror(ebuf); @@ -2687,6 +2688,7 @@ logerror("socket"); continue; } +#ifdef INET6 if (r->ai_family == AF_INET6) { if (setsockopt(*s, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&on, sizeof (on)) < 0) { @@ -2695,6 +2697,7 @@ continue; } } +#endif if (setsockopt(*s, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof (on)) < 0) { logerror("setsockopt"); @@ -2711,8 +2714,8 @@ */ if (!NoBind) { if (bind(*s, r->ai_addr, r->ai_addrlen) < 0) { + logerror("bind"); close(*s); - logerror("bind"); continue; } >Release-Note: >Audit-Trail: >Unformatted: