加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Fix-interface-parsing-code-to-look-for-null-ifc-addrs.patch 2.48 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 11:10 . Package init
# 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)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化