Ticket #281: trac-281-fix.patch

File trac-281-fix.patch, 1.3 KB (added by Gert Döring, 9 years ago)

this should both fix the segv (due to checking rl via ASSERT) and the underlying problem (route_list is now always initialized)

  • src/openvpn/init.c

    diff --git a/src/openvpn/init.c b/src/openvpn/init.c
    index 98f5489..694d086 100644
    a b do_init_traffic_shaper (struct context *c) 
    11451145}
    11461146
    11471147/*
    1148  * Allocate a route list structure if at least one
    1149  * --route option was specified.
     1148 * Allocate route list structures for IPv4 and IPv6
     1149 * (we do this for IPv4 even if no --route option has been seen, as other
     1150 * parts of OpenVPN might want to fill the route-list with info, e.g. DHCP)
    11501151 */
    11511152static void
    11521153do_alloc_route_list (struct context *c)
    11531154{
    1154   if (c->options.routes && !c->c1.route_list)
     1155  if (!c->c1.route_list)
    11551156    c->c1.route_list = new_route_list (c->options.max_routes, &c->gc);
    11561157  if (c->options.routes_ipv6 && !c->c1.route_ipv6_list)
    11571158    c->c1.route_ipv6_list = new_route_ipv6_list (c->options.max_routes, &c->gc);
  • src/openvpn/route.c

    diff --git a/src/openvpn/route.c b/src/openvpn/route.c
    index f5b5efa..72ecbaf 100644
    a b route_list_add_vpn_gateway (struct route_list *rl, 
    503503                            struct env_set *es,
    504504                            const in_addr_t addr)
    505505{
     506  ASSERT(rl);
    506507  rl->spec.remote_endpoint = addr;
    507508  rl->spec.flags |= RTSA_REMOTE_ENDPOINT;
    508509  setenv_route_addr (es, "vpn_gateway", rl->spec.remote_endpoint, -1);