Avoid a null dereference if IFF_BROADCAST is set but there is no broadcast address

It seems that the getifaddrs() function can return interfaces with
IFF_BROADCAST & IFF_UP set, but no broadcast address (at least
under Cygwin 1.7, this seems to happen for v6 mapped v4 addresses)

Avoid a null dereference if this ever happens

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
Jon TURNEY 2009-11-01 18:19:14 +00:00
parent 091cbbaed7
commit 28eb61fc04

View File

@ -811,7 +811,8 @@ DefineSelf (int fd)
continue;
#endif
if ((ifr->ifa_flags & IFF_BROADCAST) &&
(ifr->ifa_flags & IFF_UP))
(ifr->ifa_flags & IFF_UP) &&
ifr->ifa_broadaddr)
broad_addr = *ifr->ifa_broadaddr;
else
continue;