Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/syslogd PR/47861: Fredrik Pettai: keep track of the...



details:   https://anonhg.NetBSD.org/src/rev/b7c860df8346
branches:  trunk
changeset: 786983:b7c860df8346
user:      christos <christos%NetBSD.org@localhost>
date:      Mon May 27 23:15:51 2013 +0000

description:
PR/47861: Fredrik Pettai: keep track of the address family for each socket
opened and don't send the a message to the wrong family type.

diffstat:

 usr.sbin/syslogd/syslogd.c |  7 +++++--
 usr.sbin/syslogd/syslogd.h |  3 ++-
 usr.sbin/syslogd/tls.c     |  5 +++--
 3 files changed, 10 insertions(+), 5 deletions(-)

diffs (78 lines):

diff -r 368016ddd487 -r b7c860df8346 usr.sbin/syslogd/syslogd.c
--- a/usr.sbin/syslogd/syslogd.c        Mon May 27 21:32:38 2013 +0000
+++ b/usr.sbin/syslogd/syslogd.c        Mon May 27 23:15:51 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syslogd.c,v 1.114 2013/01/17 18:54:28 christos Exp $   */
+/*     $NetBSD: syslogd.c,v 1.115 2013/05/27 23:15:51 christos Exp $   */
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)syslogd.c  8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.114 2013/01/17 18:54:28 christos Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.115 2013/05/27 23:15:51 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -2496,6 +2496,8 @@
        for (r = f->f_un.f_forw.f_addr; r; r = r->ai_next) {
                retry = 0;
                for (j = 0; j < finet->fd; j++) {
+                       if (finet[j+1].af != r->ai_family)
+                               continue;
 sendagain:
                        lsent = sendto(finet[j+1].fd, line, len, 0,
                            r->ai_addr, r->ai_addrlen);
@@ -3994,6 +3996,7 @@
                        logerror("socket() failed");
                        continue;
                }
+               s->af = r->ai_family;
                if (r->ai_family == AF_INET6 && setsockopt(s->fd, IPPROTO_IPV6,
                    IPV6_V6ONLY, &on, sizeof(on)) < 0) {
                        logerror("setsockopt(IPV6_V6ONLY) failed");
diff -r 368016ddd487 -r b7c860df8346 usr.sbin/syslogd/syslogd.h
--- a/usr.sbin/syslogd/syslogd.h        Mon May 27 21:32:38 2013 +0000
+++ b/usr.sbin/syslogd/syslogd.h        Mon May 27 23:15:51 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syslogd.h,v 1.3 2009/04/20 09:56:08 mschuett Exp $     */
+/*     $NetBSD: syslogd.h,v 1.4 2013/05/27 23:15:51 christos Exp $     */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -302,6 +302,7 @@
 /* a pair of a socket and an associated event object */
 struct socketEvent {
        int fd;
+       int af;
        struct event *ev;
 };
 
diff -r 368016ddd487 -r b7c860df8346 usr.sbin/syslogd/tls.c
--- a/usr.sbin/syslogd/tls.c    Mon May 27 21:32:38 2013 +0000
+++ b/usr.sbin/syslogd/tls.c    Mon May 27 23:15:51 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tls.c,v 1.10 2012/06/06 00:33:45 christos Exp $        */
+/*     $NetBSD: tls.c,v 1.11 2013/05/27 23:15:51 christos Exp $        */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: tls.c,v 1.10 2012/06/06 00:33:45 christos Exp $");
+__RCSID("$NetBSD: tls.c,v 1.11 2013/05/27 23:15:51 christos Exp $");
 
 #ifndef DISABLE_TLS
 #include "syslogd.h"
@@ -851,6 +851,7 @@
                        logerror("socket() failed: %s", strerror(errno));
                        continue;
                }
+               s->af = r->ai_family;
                if (r->ai_family == AF_INET6
                 && setsockopt(s->fd, IPPROTO_IPV6, IPV6_V6ONLY,
                        &on, sizeof(on)) == -1) {



Home | Main Index | Thread Index | Old Index