Starting slpd with ipv6 and SLIP segfaults
Brought to you by:
jcalcote
If you start slpd and have SLIP enabled and are using IPv6 addresses on the eth ports, slpd will segfault.
The parsing of getifaddrs needs to ignore the slxxx devices when parsing the list of devices passed back.
A simple change to slp_iface.c when parsing the devices will correct the problem. The following will resolve the problem on Linux systems:
for (; ifa; ifa = ifa->ifa_next) {
+ if(!ifa->ifa_addr)
+ continue;
+ if(strstr("sl", ifa->ifa_name) != 0)
+ continue;
+
Here is a patch for this bug against the latest code that uses getifaddrs. Attachments were not available.
Index: openslp/common/slp_iface.c
--- openslp/common/slp_iface.c (revision 1648)
+++ openslp/common/slp_iface.c (working copy)
@@ -169,6 +169,10 @@
if (!iface) {
for (; ifa; ifa = ifa->ifa_next) {
+ if (!ifa->ifa_addr)
+ continue;
+ if (strstr("sl", ifa->ifa_name) != 0)
+ continue;
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
paddr = (struct sockaddr_in6 *)ifa->ifa_addr;
@@ -183,6 +187,10 @@
}
for (; ifa; ifa = ifa->ifa_next) {
+ if (!ifa->ifa_addr)
+ continue;
+ if (strstr("sl", ifa->ifa_name) != 0)
+ continue;
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
paddr = (struct sockaddr_in6 *)ifa->ifa_addr;
@@ -355,6 +363,10 @@
for (; ifa; ifa = ifa->ifa_next)
{
+ if (!ifa->ifa_addr)
+ continue;
+ if (strstr("sl", ifa->ifa_name) != 0)
+ continue;
if(ifa->ifa_addr->sa_family != AF_INET6)
continue;
@@ -850,6 +862,10 @@
}
ifaddr = ifa;
for (; ifa; ifa = ifa->ifa_next) {
+ if (!ifa->ifa_addr)
+ continue;
+ if (strstr("sl", ifa->ifa_name) != 0)
+ continue;
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
if(((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_scope_id == scope_id) {
Hi Pete, The patch looks ok to me. This does not touch any other OS functionality so iam ok. Iam not able to apply the patch. You must be able to attach it. If you are not, can you send the patch by mail?
I had the same problem with some other type of device: tun0. So, I would rather test for the ifa_addr being not NULL
for (; ifa; ifa = ifa->ifa_next)
{
if (ifa->ifa_addr == NULL )
continue;
man getifaddrs states:
The ifa_addr field points to a structure containing the interface address. (The sa_family subfield should be consulted to determine the format of the
address structure.) This field may contain a NULL pointer.
I added the checks for null ifa_addr fields, but left out the filters for SLIP interfaces. The proper way to filter interfaces is to specify the interfaces you want OpenSLP to use in the openslp properties file. There may actualy be people who want to use OpenSLP with their SLIP connections (who knows?!).
Fixed in mercurial commit #1783.