82 lines
2.5 KiB
Diff
82 lines
2.5 KiB
Diff
# HG changeset patch
|
|
# User John Calcote <john.calcote@gmail.com>
|
|
# Date 1491593654 21600
|
|
# Fri Apr 07 13:34:14 2017 -0600
|
|
# Node ID 95e918d8e0d90ffa7902073c1e70c976e00cc0b0
|
|
# Parent 5f989105ddc62829adbb3ac1c36a51bd927ba1d9
|
|
BUG#123: Fix interface parsing code to look for null ifc addrs.
|
|
|
|
diff -r 5f989105ddc6 -r 95e918d8e0d9 common/slp_iface.c
|
|
--- a/common/slp_iface.c Fri Apr 07 12:41:37 2017 -0600
|
|
+++ b/common/slp_iface.c Fri Apr 07 13:34:14 2017 -0600
|
|
@@ -417,8 +417,14 @@
|
|
{
|
|
for (; ifa; ifa = ifa->ifa_next)
|
|
{
|
|
+ /* filter out NULL address interfaces */
|
|
+ if (!ifa->ifa_addr)
|
|
+ continue;
|
|
+
|
|
+ /* filter out non-v6 interfaces */
|
|
if (ifa->ifa_addr->sa_family != AF_INET6)
|
|
continue;
|
|
+
|
|
paddr = (struct sockaddr_in6 *)ifa->ifa_addr;
|
|
if (!memcmp(&paddr->sin6_addr, &addr->sin6_addr, sizeof(struct in6_addr)))
|
|
{
|
|
@@ -433,8 +439,14 @@
|
|
|
|
for (; ifa; ifa = ifa->ifa_next)
|
|
{
|
|
+ /* filter out NULL address interfaces */
|
|
+ if (!ifa->ifa_addr)
|
|
+ continue;
|
|
+
|
|
+ /* filter out non-v6 interfaces */
|
|
if (ifa->ifa_addr->sa_family != AF_INET6)
|
|
continue;
|
|
+
|
|
paddr = (struct sockaddr_in6 *)ifa->ifa_addr;
|
|
if ((!strcmp(iface, ifa->ifa_name)) && (!memcmp(&paddr->sin6_addr, &addr->sin6_addr, sizeof(struct in6_addr))))
|
|
{
|
|
@@ -600,9 +612,15 @@
|
|
|
|
for (ifa = ifaddrs; ifa && ifaceinfo->iface_count < slp_max_ifaces; ifa = ifa->ifa_next)
|
|
{
|
|
+ /* filter out NULL address interfaces */
|
|
+ if (!ifa->ifa_addr)
|
|
+ continue;
|
|
+
|
|
+ /* filter out non-v6 interfaces */
|
|
if (ifa->ifa_addr->sa_family != AF_INET6)
|
|
continue;
|
|
|
|
+ /* filter out loopback interfaces */
|
|
if (!strcmp("lo", ifa->ifa_name))
|
|
continue;
|
|
|
|
@@ -1135,7 +1153,7 @@
|
|
return sts;
|
|
}
|
|
|
|
-/** Extract Interface Name from scope id.
|
|
+/** Extract Interface Name from scope id. This function is called by v6 code only.
|
|
*
|
|
* @param[in] scope_id - The scope id of interface
|
|
* @param[in,out] iface - The interface name got from scope id
|
|
@@ -1156,8 +1174,14 @@
|
|
ifaddr = ifa;
|
|
for (; ifa; ifa = ifa->ifa_next)
|
|
{
|
|
+ /* filter out NULL address interfaces */
|
|
+ if (!ifa->ifa_addr)
|
|
+ continue;
|
|
+
|
|
+ /* filter out non-v6 interfaces */
|
|
if (ifa->ifa_addr->sa_family != AF_INET6)
|
|
continue;
|
|
+
|
|
if (((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_scope_id == scope_id)
|
|
{
|
|
if (strlen(ifa->ifa_name) >= MAX_IFACE_LEN)
|