summaryrefslogtreecommitdiff
path: root/interface-ip.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2020-08-09 22:46:54 +0200
committerHans Dedecker <dedeckeh@gmail.com>2020-08-10 21:20:52 +0200
commit645ceed0ed706b073edd6a0d5a2eb936208b48c9 (patch)
treebcf841c0f4c1075f6e2a2f15c598e9115a728414 /interface-ip.c
parente32e21e8f338045f410293fab928c9166bf8a44e (diff)
downloadnetifd-645ceed0ed706b073edd6a0d5a2eb936208b48c9.tar.gz
interface-ip: clear host bits of the device prefix
Clear the host bits of the device prefix in interface_ip_add_device_prefix as interface_set_prefix_address just ORs the calculated assignment part which would lead to an invalid IPv6 address if the host bits are not masked out Suggested-by: Daniel Gröber <dxld@darkboxed.org> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'interface-ip.c')
-rw-r--r--interface-ip.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/interface-ip.c b/interface-ip.c
index 2e46f14..f1ed8d3 100644
--- a/interface-ip.c
+++ b/interface-ip.c
@@ -1270,6 +1270,8 @@ interface_ip_add_device_prefix(struct interface *iface, struct in6_addr *addr,
uint8_t length, time_t valid_until, time_t preferred_until,
struct in6_addr *excl_addr, uint8_t excl_length, const char *pclass)
{
+ union if_addr a = { .in6 = *addr };
+
if (!pclass)
pclass = (iface) ? iface->name : "local";
@@ -1277,8 +1279,10 @@ interface_ip_add_device_prefix(struct interface *iface, struct in6_addr *addr,
if (!prefix)
return NULL;
+ clear_if_addr(&a, length);
+
prefix->length = length;
- prefix->addr = *addr;
+ prefix->addr = a.in6;
prefix->preferred_until = preferred_until;
prefix->valid_until = valid_until;
prefix->iface = iface;