Fix a memory corruption when updating IPv6 prefixes
authorSteven Barth <steven@midlink.org>
Fri, 5 Apr 2013 13:25:38 +0000 (15:25 +0200)
committerSteven Barth <steven@midlink.org>
Fri, 5 Apr 2013 13:25:38 +0000 (15:25 +0200)
interface-ip.c

index 2b876618c9d50efbadb80984bcac27973e4fe8a6..7155fe4a404ba09f2ba87bb33b2dc2cdc120db29 100644 (file)
@@ -647,7 +647,7 @@ interface_update_prefix(struct vlist_tree *tree,
 
        if (node_old && node_new) {
                // Move assignments and refresh addresses to update valid times
-               list_splice_init(&prefix_old->assignments, &prefix_new->assignments);
+               list_splice(&prefix_old->assignments, &prefix_new->assignments);
 
                list_for_each_entry(c, &prefix_new->assignments, head)
                        if ((iface = vlist_find(&interfaces, c->name, iface, node)))
@@ -656,7 +656,6 @@ interface_update_prefix(struct vlist_tree *tree,
                // Set null-route to avoid routing loops
                system_add_route(NULL, &route);
 
-               INIT_LIST_HEAD(&prefix_new->assignments);
                interface_update_prefix_assignments(prefix_new, true);
        } else if (node_old) {
                interface_update_prefix_assignments(prefix_old, false);
@@ -686,6 +685,7 @@ interface_ip_add_device_prefix(struct interface *iface, struct in6_addr *addr,
        prefix->preferred_until = preferred_until;
        prefix->valid_until = valid_until;
        prefix->iface = iface;
+       INIT_LIST_HEAD(&prefix->assignments);
 
        if (excl_addr) {
                prefix->excl_addr = *excl_addr;