NL_CAPABILITY_RTNL_ADDR_PEER_ID_FIX = 20,
#define NL_CAPABILITY_RTNL_ADDR_PEER_ID_FIX NL_CAPABILITY_RTNL_ADDR_PEER_ID_FIX
+ /**
+ * nl_addr_fill_sockaddr() properly checks that the provided address to
+ * avoid read-out-of-bounds for invalid addresses.
+ */
+ NL_CAPABILITY_NL_ADDR_FILL_SOCKADDR = 21,
+#define NL_CAPABILITY_NL_ADDR_FILL_SOCKADDR NL_CAPABILITY_NL_ADDR_FILL_SOCKADDR
+
__NL_CAPABILITY_MAX,
NL_CAPABILITY_MAX = (__NL_CAPABILITY_MAX - 1),
#define NL_CAPABILITY_MAX NL_CAPABILITY_MAX
if (*salen < sizeof(*sai))
return -NLE_INVAL;
+ if (addr->a_len == 4)
+ memcpy(&sai->sin_addr, addr->a_addr, 4);
+ else if (addr->a_len != 0)
+ return -NLE_INVAL;
+ else
+ memset(&sai->sin_addr, 0, 4);
+
sai->sin_family = addr->a_family;
- memcpy(&sai->sin_addr, addr->a_addr, 4);
*salen = sizeof(*sai);
}
break;
if (*salen < sizeof(*sa6))
return -NLE_INVAL;
+ if (addr->a_len == 16)
+ memcpy(&sa6->sin6_addr, addr->a_addr, 16);
+ else if (addr->a_len != 0)
+ return -NLE_INVAL;
+ else
+ memset(&sa6->sin6_addr, 0, 16);
+
sa6->sin6_family = addr->a_family;
- memcpy(&sa6->sin6_addr, addr->a_addr, 16);
*salen = sizeof(*sa6);
}
break;
NL_CAPABILITY_RTNL_ADDR_PEER_FIX,
NL_CAPABILITY_VERSION_3_2_28,
NL_CAPABILITY_RTNL_ADDR_PEER_ID_FIX,
- 0,
+ NL_CAPABILITY_NL_ADDR_FILL_SOCKADDR,
0,
0,
0),