added additional checks on structure returned by getifaddrs()
This commit is contained in:
parent
63a83f8a0a
commit
8f68347464
|
@ -2,6 +2,7 @@ $Id: Changelog.txt,v 1.242 2011/11/18 11:21:20 nanard Exp $
|
|||
|
||||
2012/01/02:
|
||||
Fixing netfilter/iptables_*.sh scripts for new ifconfig output format.
|
||||
getifaddr.c: added additional checks on structure returned by getifaddrs()
|
||||
|
||||
2011/11/18:
|
||||
avoid infinite loop in SendResp_upnphttp() in case of error
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: getifaddr.c,v 1.11 2011/05/15 08:59:27 nanard Exp $ */
|
||||
/* $Id: getifaddr.c,v 1.12 2012/01/02 10:08:42 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2011 Thomas Bernard
|
||||
|
@ -74,8 +74,10 @@ getifaddr(const char * ifname, char * buf, int len)
|
|||
}
|
||||
for(ife = ifap; ife; ife = ife->ifa_next)
|
||||
{
|
||||
/* skip other interfaces */
|
||||
if(0 != strcmp(ifname, ife->ifa_name))
|
||||
/* skip other interfaces if one was specified */
|
||||
if(ifname && (0 != strcmp(ifname, ife->ifa_name)))
|
||||
continue;
|
||||
if(ife->ifa_addr == NULL)
|
||||
continue;
|
||||
switch(ife->ifa_addr->sa_family)
|
||||
{
|
||||
|
@ -121,6 +123,8 @@ find_ipv6_addr(const char * ifname,
|
|||
/* skip other interfaces if one was specified */
|
||||
if(ifname && (0 != strcmp(ifname, ife->ifa_name)))
|
||||
continue;
|
||||
if(ife->ifa_addr == NULL)
|
||||
continue;
|
||||
if(ife->ifa_addr->sa_family == AF_INET6)
|
||||
{
|
||||
addr = (const struct sockaddr_in6 *)ife->ifa_addr;
|
||||
|
|
Loading…
Reference in New Issue