Make sure the if_name member of cached route entries is initialized to NULL
authorTobias Brunner <tobias@strongswan.org>
Sat, 22 Sep 2012 06:23:56 +0000 (08:23 +0200)
committerTobias Brunner <tobias@strongswan.org>
Sat, 22 Sep 2012 06:23:56 +0000 (08:23 +0200)
src/libhydra/plugins/kernel_netlink/kernel_netlink_ipsec.c
src/libhydra/plugins/kernel_pfkey/kernel_pfkey_ipsec.c

index cfd85a5..654a1c6 100644 (file)
@@ -2159,8 +2159,12 @@ static status_t add_policy_internal(private_kernel_netlink_ipsec_t *this,
        if (policy->direction == POLICY_FWD &&
                ipsec->cfg.mode != MODE_TRANSPORT && this->install_routes)
        {
-               route_entry_t *route = malloc_thing(route_entry_t);
                policy_sa_fwd_t *fwd = (policy_sa_fwd_t*)mapping;
+               route_entry_t *route;
+
+               INIT(route,
+                       .prefixlen = policy->sel.prefixlen_s,
+               );
 
                if (hydra->kernel_interface->get_address_by_ts(hydra->kernel_interface,
                                fwd->dst_ts, &route->src_ip) == SUCCESS)
@@ -2171,7 +2175,6 @@ static status_t add_policy_internal(private_kernel_netlink_ipsec_t *this,
                                                                                        ipsec->dst);
                        route->dst_net = chunk_alloc(policy->sel.family == AF_INET ? 4 : 16);
                        memcpy(route->dst_net.ptr, &policy->sel.saddr, route->dst_net.len);
-                       route->prefixlen = policy->sel.prefixlen_s;
 
                        /* install route via outgoing interface */
                        if (!hydra->kernel_interface->get_interface(hydra->kernel_interface,
index 14ca4c8..c004b6f 100644 (file)
@@ -2018,8 +2018,12 @@ static status_t add_policy_internal(private_kernel_pfkey_ipsec_t *this,
        if (policy->direction == POLICY_FWD &&
                ipsec->cfg.mode != MODE_TRANSPORT && this->install_routes)
        {
-               route_entry_t *route = malloc_thing(route_entry_t);
                policy_sa_fwd_t *fwd = (policy_sa_fwd_t*)mapping;
+               route_entry_t *route;
+
+               INIT(route,
+                       .prefixlen = policy->src.mask,
+               );
 
                if (hydra->kernel_interface->get_address_by_ts(hydra->kernel_interface,
                                fwd->dst_ts, &route->src_ip) == SUCCESS)
@@ -2030,7 +2034,6 @@ static status_t add_policy_internal(private_kernel_pfkey_ipsec_t *this,
                                                                                        ipsec->dst);
                        route->dst_net = chunk_clone(policy->src.net->get_address(
                                                                                        policy->src.net));
-                       route->prefixlen = policy->src.mask;
 
                        /* install route via outgoing interface */
                        if (!hydra->kernel_interface->get_interface(hydra->kernel_interface,