radvd-project / radvd

radvd | Official repository: https://github.com/radvd-project/radvd
https://radvd.litech.org/
Other
203 stars 106 forks source link

segfaults in send.c:add_auto_prefixes for devices having ifaddrs.ifa_addr == NULL #112

Closed hxx-fetch closed 5 years ago

hxx-fetch commented 5 years ago

On 2.18 I had radvd starting segfaulting, when I added a wireguard interface to the system.

Debugging showed that send.c line 293 is the culprid. Following patch fixed the segfaults:

--- radvd-2.18/send.c   2018-12-08 23:35:39.000000000 -0000
+++ radvd-2.18.patched/send.c   2019-09-21 20:13:28.986666845 -0000
@@ -289,6 +289,11 @@

                if (strncmp(ifa->ifa_name, ifname, IFNAMSIZ))
                        continue;
+
+               if (ifa->ifa_addr == NULL) {
+                       flog(LOG_ERR, "ifa_addr == NULL for dev %s !? Ignoring in add_auto_prefixes", ifname);
+                       continue;
+               }

According to the man page of getifaddrs is seems actually valid for ifa_addr to be NULL.

reubenhwk commented 5 years ago

Can you turn this into a pull request?