From 5bcca953bed3e570c0918da5419b4bc5e8856bcf Mon Sep 17 00:00:00 2001 From: mbr Date: Mon, 27 Jan 2003 22:43:23 +0000 Subject: 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 --- lib/libc/rpc/clnt_bcast.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/rpc/clnt_bcast.c b/lib/libc/rpc/clnt_bcast.c index 03fdf61d..d827820 100644 --- a/lib/libc/rpc/clnt_bcast.c +++ b/lib/libc/rpc/clnt_bcast.c @@ -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++; -- cgit v1.1