]> git.meshlink.io Git - meshlink/commitdiff
Fix a crash with some network configurations.
authorGuus Sliepen <guus@meshlink.io>
Fri, 10 Jul 2020 20:15:39 +0000 (22:15 +0200)
committerGuus Sliepen <guus@meshlink.io>
Fri, 10 Jul 2020 20:15:39 +0000 (22:15 +0200)
It is apparently possible for getifaddrs() to return a struct ifaddrs that
contains a NULL ifa_addr pointer.

src/meshlink.c

index 0fe7343c7ae6a789ab517f2973a6ab5920970c84..d54fe30b1ae8f49500214036709f983b6a015ba3 100644 (file)
@@ -366,7 +366,7 @@ char *meshlink_get_local_address_for_family(meshlink_handle_t *mesh, int family)
                for(struct ifaddrs *ifap = ifa; ifap; ifap = ifap->ifa_next) {
                        sockaddr_t *sa = (sockaddr_t *)ifap->ifa_addr;
 
-                       if(sa->sa.sa_family != family) {
+                       if(!sa || sa->sa.sa_family != family) {
                                continue;
                        }