mirror of
https://github.com/opnsense/src.git
synced 2026-06-08 16:22:46 -04:00
Make this work in the !INET6 case -- if we mismatch the AF, don't return a
bogus (uninitialized) structure. Also, ignore v4 ifa's with no broadcast address (rather than core dumping). NetBSD Rev 1.8 Reviewed by: phk Obtained from: NetBSD
This commit is contained in:
parent
d063ef1461
commit
33e0ae486e
1 changed files with 10 additions and 9 deletions
|
|
@ -149,28 +149,25 @@ __rpc_getbroadifs(int af, int proto, int socktype, broadlist_t *list)
|
|||
if (ifap->ifa_addr->sa_family != af ||
|
||||
!(ifap->ifa_flags & IFF_UP))
|
||||
continue;
|
||||
#ifdef INET6
|
||||
if ((af == AF_INET6 && !(ifap->ifa_flags & IFF_MULTICAST)) ||
|
||||
!(ifap->ifa_flags & IFF_BROADCAST))
|
||||
continue;
|
||||
#endif
|
||||
bip = (struct broadif *)malloc(sizeof *bip);
|
||||
if (bip == NULL)
|
||||
break;
|
||||
bip->index = if_nametoindex(ifap->ifa_name);
|
||||
if (
|
||||
#ifdef INET6
|
||||
if (af != AF_INET6 && (ifap->ifa_flags & IFF_BROADCAST)) {
|
||||
#else
|
||||
if (ifap->ifa_flags & IFF_BROADCAST) {
|
||||
af != AF_INET6 &&
|
||||
#endif
|
||||
(ifap->ifa_flags & IFF_BROADCAST) &&
|
||||
ifap->ifa_broadaddr) {
|
||||
memcpy(&bip->broadaddr, ifap->ifa_broadaddr,
|
||||
(size_t)ifap->ifa_broadaddr->sa_len);
|
||||
sin = (struct sockaddr_in *)(void *)&bip->broadaddr;
|
||||
sin->sin_port =
|
||||
((struct sockaddr_in *)
|
||||
(void *)res->ai_addr)->sin_port;
|
||||
} else
|
||||
#ifdef INET6
|
||||
} else if (af == AF_INET6) {
|
||||
if (af == AF_INET6 && (ifap->ifa_flags & IFF_MULTICAST)) {
|
||||
sin6 = (struct sockaddr_in6 *)(void *)&bip->broadaddr;
|
||||
inet_pton(af, RPCB_MULTICAST_ADDR, &sin6->sin6_addr);
|
||||
sin6->sin6_family = af;
|
||||
|
|
@ -179,7 +176,11 @@ __rpc_getbroadifs(int af, int proto, int socktype, broadlist_t *list)
|
|||
((struct sockaddr_in6 *)
|
||||
(void *)res->ai_addr)->sin6_port;
|
||||
sin6->sin6_scope_id = bip->index;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
free(bip);
|
||||
continue;
|
||||
}
|
||||
TAILQ_INSERT_TAIL(list, bip, link);
|
||||
count++;
|
||||
|
|
|
|||
Loading…
Reference in a new issue