]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix NULL-pointer crash in route_list_add_vpn_gateway().
authorGert Doering <gert@greenie.muc.de>
Fri, 3 May 2013 19:13:24 +0000 (21:13 +0200)
committerGert Doering <gert@greenie.muc.de>
Sat, 18 May 2013 10:18:10 +0000 (12:18 +0200)
Add ASSERT() check to route_list_add_vpn_gateway() to ensure that *rl
is valid (and if not, crash with a somewhat more meaningful message than
"segmentation violation").  For the actual bugfix, change init code to
always allocate a "struct route_list" for IPv4, even if no --route options
have been seen in the config.

Fix trac#281 and trac#258.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Josh Cepek <josh.cepek@usa.net>
Message-Id: <1367608404-2257-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/7581
(cherry picked from commit eb95f367348f4c2aae301cfa7c3adc8e0f2e711e)

src/openvpn/init.c
src/openvpn/route.c

index 979ba231e09fb609df8062b5fc368d268a314489..5260d43c39d9b18048f8706bf2b8cfda846599d8 100644 (file)
@@ -1145,13 +1145,14 @@ do_init_traffic_shaper (struct context *c)
 }
 
 /*
- * Allocate a route list structure if at least one
- * --route option was specified.
+ * Allocate route list structures for IPv4 and IPv6
+ * (we do this for IPv4 even if no --route option has been seen, as other
+ * parts of OpenVPN might want to fill the route-list with info, e.g. DHCP)
  */
 static void
 do_alloc_route_list (struct context *c)
 {
-  if (c->options.routes && !c->c1.route_list)
+  if (!c->c1.route_list)
     c->c1.route_list = new_route_list (c->options.max_routes, &c->gc);
   if (c->options.routes_ipv6 && !c->c1.route_ipv6_list)
     c->c1.route_ipv6_list = new_route_ipv6_list (c->options.max_routes, &c->gc);
index 4c1e14e91d8c2692c12b19bc33c6c929d281394c..044e6ac06fb448cc0dd4dcc94316d6e8739a3990 100644 (file)
@@ -503,6 +503,7 @@ route_list_add_vpn_gateway (struct route_list *rl,
                            struct env_set *es,
                            const in_addr_t addr)
 {
+  ASSERT(rl);
   rl->spec.remote_endpoint = addr;
   rl->spec.flags |= RTSA_REMOTE_ENDPOINT;
   setenv_route_addr (es, "vpn_gateway", rl->spec.remote_endpoint, -1);