Check ifa->ifa_addr otherwise existing TUN device causes following segfault;
authorS.Çağlar Onur <caglar@cs.princeton.edu>
Tue, 12 Oct 2010 19:09:08 +0000 (15:09 -0400)
committerS.Çağlar Onur <caglar@cs.princeton.edu>
Tue, 12 Oct 2010 19:09:08 +0000 (15:09 -0400)
>>> import vserver
>>> q = vserver.VServer("princeton_caglar")
>>> q.set_ipaddresses_config("0.0.0.0")

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1220499776 (LWP 831)]
0xb72a8556 in get_mask (addr=0xbfa7761c) at python/vserverimpl.c:404
404         if (ifa->ifa_addr->sa_family == family &&

tun1095-0 Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

python/vserverimpl.c

index c1725f3..1f0d913 100644 (file)
@@ -401,7 +401,7 @@ get_mask(struct vc_net_addr *addr)
   if (getifaddrs(&head) == -1)
     return -1;
   for (ifa = head; ifa; ifa = ifa->ifa_next) {
-    if (ifa->ifa_addr->sa_family == family &&
+    if (ifa->ifa_addr && ifa->ifa_addr->sa_family == family &&
         memcmp((char *) ifa->ifa_addr + offset, ip, len) == 0) {
       switch (addr->vna_type) {
       case VC_NXA_TYPE_IPV4: