Fix some seg fault with venet nic

FossilOrigin-Name: 8873064065f3e7e58db46f80bcc73b9373cd2862b877707de6036f0238d7b0a9
This commit is contained in:
alexis.lagoutte@gmail.com 2016-03-25 18:31:43 +00:00
parent 28a1e50d6b
commit f7ffd93d3b
2 changed files with 15 additions and 0 deletions

View File

@ -361,6 +361,9 @@ static int init_listen_addrs()
/* count the addresses */ /* count the addresses */
int ctr = 0; int ctr = 0;
for (ifa = ifap; ifa != 0; ifa = ifa->ifa_next) { for (ifa = ifap; ifa != 0; ifa = ifa->ifa_next) {
if (!ifa->ifa_addr)
continue;
if (ifa->ifa_addr->sa_family == AF_INET && conf_ipv4) if (ifa->ifa_addr->sa_family == AF_INET && conf_ipv4)
ctr++; ctr++;
#ifdef WITH_IPV6 #ifdef WITH_IPV6
@ -388,6 +391,8 @@ static int init_listen_addrs()
continue; continue;
} }
} }
if (!ifa->ifa_addr)
continue;
if (ifa->ifa_addr->sa_family == AF_INET && conf_ipv4) { if (ifa->ifa_addr->sa_family == AF_INET && conf_ipv4) {
sock_addrtostr(ifa->ifa_addr, str, 100,0); sock_addrtostr(ifa->ifa_addr, str, 100,0);
@ -492,6 +497,8 @@ int init_bcast_addrs()
sa = ifa->ifa_addr; sa = ifa->ifa_addr;
if (!sa)
continue;
if (sa->sa_family != AF_INET) if (sa->sa_family != AF_INET)
continue; continue;

View File

@ -47,6 +47,14 @@ int sock_cmpaddr(const struct sockaddr *addr1, const struct sockaddr *addr2,int
int p1,p2; int p1,p2;
int slen; int slen;
if (!addr1){
return -1;
}
if (!addr2){
return -1;
}
if (addr1->sa_family != addr2->sa_family){ if (addr1->sa_family != addr2->sa_family){
return addr1->sa_family - addr2->sa_family; return addr1->sa_family - addr2->sa_family;
} }