From 72f1f558f1e4261e4a10b5cefc77c9ac76f9bbff Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 2 Apr 2011 03:48:00 +0200 Subject: [PATCH] iface: use interface values only when valid https://bugzilla.redhat.com/show_bug.cgi?id=690416 --- avahi-core/socket.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/avahi-core/socket.c b/avahi-core/socket.c index e69ec7d..a4ffd70 100644 --- a/avahi-core/socket.c +++ b/avahi-core/socket.c @@ -726,7 +726,7 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv4( case IP_PKTINFO: { struct in_pktinfo *i = (struct in_pktinfo*) CMSG_DATA(cmsg); - if (ret_iface) + if (ret_iface && i->ipi_ifindex > 0) *ret_iface = (int) i->ipi_ifindex; if (ret_dst_address) @@ -742,12 +742,16 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv4( case IP_RECVIF: { struct sockaddr_dl *sdl = (struct sockaddr_dl *) CMSG_DATA (cmsg); - if (ret_iface) + if (ret_iface) { #ifdef __sun - *ret_iface = *(uint_t*) sdl; + if (*(uint_t*) sdl > 0) + *ret_iface = *(uint_t*) sdl; #else - *ret_iface = (int) sdl->sdl_index; + + if (sdl->sdl_index > 0) + *ret_iface = (int) sdl->sdl_index; #endif + } break; } @@ -874,7 +878,7 @@ AvahiDnsPacket *avahi_recv_dns_packet_ipv6( case IPV6_PKTINFO: { struct in6_pktinfo *i = (struct in6_pktinfo*) CMSG_DATA(cmsg); - if (ret_iface) + if (ret_iface && i->ipi6_ifindex > 0) *ret_iface = i->ipi6_ifindex; if (ret_dst_address) -- 2.39.5