From 6edca3394db1a45599b51db70330da5f96383555 Mon Sep 17 00:00:00 2001 From: markj Date: Thu, 20 Dec 2012 23:21:20 +0000 Subject: - Make sure that errno isn't modified before calling logerror() in error conditions. - Don't check for AF_INET6 when compiled without INET6 support. PR: bin/173930 Submitted by: Garrett Cooper Approved by: rstone (co-mentor) MFC after: 1 week --- usr.sbin/syslogd/syslogd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'usr.sbin/syslogd') diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index fff7e4c..bb56b6b 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1873,6 +1873,7 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) pri = decode(buf, prioritynames); if (pri < 0) { + errno = 0; (void)snprintf(ebuf, sizeof ebuf, "unknown priority name \"%s\"", buf); logerror(ebuf); @@ -1901,6 +1902,7 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host) } else { i = decode(buf, facilitynames); if (i < 0) { + errno = 0; (void)snprintf(ebuf, sizeof ebuf, "unknown facility name \"%s\"", buf); @@ -2687,6 +2689,7 @@ socksetup(int af, char *bindhostname) 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 +2698,7 @@ socksetup(int af, char *bindhostname) continue; } } +#endif if (setsockopt(*s, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof (on)) < 0) { logerror("setsockopt"); @@ -2711,8 +2715,8 @@ socksetup(int af, char *bindhostname) */ if (!NoBind) { if (bind(*s, r->ai_addr, r->ai_addrlen) < 0) { - close(*s); logerror("bind"); + close(*s); continue; } -- cgit v1.1