From 74fd29e0bc55342fa2b5d3eaa3387f0ebf083b75 Mon Sep 17 00:00:00 2001 From: Hajimu UMEMOTO Date: Thu, 19 Jul 2001 22:04:09 +0000 Subject: [PATCH] - `-a' option for IPv6 was not working correctly. - Lose any stray host bits that a user may have entered when providing a network number and netmask to the `-a' option for IPv6. This is corresponding to 1.79 that is for IPv4 only. MFC after: 1 week --- usr.sbin/syslogd/syslogd.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index dc6a7ec9e64f..3ff3233138b8 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1813,10 +1813,10 @@ allowaddr(s) char *cp1, *cp2; struct allowedpeer ap; struct servent *se; - int masklen = -1; + int masklen = -1, i; struct addrinfo hints, *res; struct in_addr *addrp, *maskp; - u_int32_t *mask6p; + u_int32_t *addr6p, *mask6p; char ip[NI_MAXHOST]; #ifdef INET6 @@ -1907,6 +1907,11 @@ allowaddr(s) *mask6p++ = 0xffffffff; masklen -= 32; } + /* Lose any host bits in the network number. */ + mask6p = (u_int32_t *)&((struct sockaddr_in6 *)&ap.a_mask)->sin6_addr; + addr6p = (u_int32_t *)&((struct sockaddr_in6 *)&ap.a_addr)->sin6_addr; + for (i = 0; i < 4; i++) + addr6p[i] &= mask6p[i]; } #endif else { @@ -2032,8 +2037,8 @@ validate(sa, hname) #endif reject = 0; for (j = 0; j < 16; j += 4) { - if ((*(u_int32_t *)&sin6->sin6_addr.s6_addr[i] & *(u_int32_t *)&m6p->sin6_addr.s6_addr[i]) - != *(u_int32_t *)&a6p->sin6_addr.s6_addr[i]) { + if ((*(u_int32_t *)&sin6->sin6_addr.s6_addr[j] & *(u_int32_t *)&m6p->sin6_addr.s6_addr[j]) + != *(u_int32_t *)&a6p->sin6_addr.s6_addr[j]) { ++reject; break; }