]> granicus.if.org Git - libnl/commitdiff
route_clone : fix segmentation fault using nl_cache_subset to filter routes
authorLoïc Touraine <ltouraine@envivio.com>
Wed, 29 Aug 2012 10:14:01 +0000 (12:14 +0200)
committerThomas Graf <tgraf@redhat.com>
Wed, 29 Aug 2012 10:14:59 +0000 (12:14 +0200)
reset the nb nhops to 0 (dst->rt_nr_nh = 0) before setting the dst->nhops
from the src->nhops

lib/route/route_obj.c

index 40a157e259c962fa4f85870109bbfc695680accd..62669a9ec2fd7fe203aa14c5043bcfaf24bd86e2 100644 (file)
@@ -110,6 +110,9 @@ static int route_clone(struct nl_object *_dst, struct nl_object *_src)
                if (!(dst->rt_pref_src = nl_addr_clone(src->rt_pref_src)))
                        return -NLE_NOMEM;
 
+       /* Will be inc'ed again while adding the nexthops of the source */
+       dst->rt_nr_nh = 0;
+
        nl_init_list_head(&dst->rt_nexthops);
        nl_list_for_each_entry(nh, &src->rt_nexthops, rtnh_list) {
                new = rtnl_route_nh_clone(nh);