svn commit: r244523 - head/usr.sbin/syslogd

Mark Johnston markj at FreeBSD.org
Thu Dec 20 23:21:21 UTC 2012


Author: markj
Date: Thu Dec 20 23:21:20 2012
New Revision: 244523
URL: http://svnweb.freebsd.org/changeset/base/244523

Log:
  - 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 <yanegomi at gmail.com>
  Approved by:	rstone (co-mentor)
  MFC after:	1 week

Modified:
  head/usr.sbin/syslogd/syslogd.c

Modified: head/usr.sbin/syslogd/syslogd.c
==============================================================================
--- head/usr.sbin/syslogd/syslogd.c	Thu Dec 20 23:18:36 2012	(r244522)
+++ head/usr.sbin/syslogd/syslogd.c	Thu Dec 20 23:21:20 2012	(r244523)
@@ -1873,6 +1873,7 @@ cfline(const char *line, struct filed *f
 
 			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
 			} 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;
 			}
 


More information about the svn-src-head mailing list