On 08/19/2013 12:47 PM, Nicolas Iooss wrote:
> The patches are working well in my testing environment with
> NetworkManager 0.9.8 but with the development revision I've got few
> issues such as https://bugzilla.gnome.org/show_bug.cgi?id=706286. Now NM
> crashes on a segmentation fault
> at 
> http://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/src/nm-policy.c#n788
>  as
> nm_vpn_connection_get_ip6_internal_gateway returns NULL for my VPN

Right. Does the attached patch fix it?

(Pavel: I briefly considered changing NMPlatform to take pointers to
struct in6_addr rather than struct in6_addr itself everywhere. it's
generally considered poor form to pass "large" structs on the stack
anyway...)

-- Dan

>From 135d790d1ad1ea240a8ccb04383aa8551cf7f2f7 Mon Sep 17 00:00:00 2001
From: Dan Winship <[email protected]>
Date: Wed, 21 Aug 2013 13:36:54 -0400
Subject: [PATCH] core: fix crash when connecting to ipv6-aware VPN

NMVpnConnection represents "no IPv6 internal gateway" as NULL, so you
can't just dereference the result. We have to pass in6addr_any to
NMPlatform in that case.
---
 src/nm-policy.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/nm-policy.c b/src/nm-policy.c
index cf94033..2707bfe 100644
--- a/src/nm-policy.c
+++ b/src/nm-policy.c
@@ -785,12 +785,14 @@ update_ip6_routing (NMPolicy *policy, gboolean force_update)
 		int parent_ifindex = nm_device_get_ip_ifindex (parent);
 		NMIP6Config *parent_ip6 = nm_device_get_ip6_config (parent);
 		guint32 parent_mss = parent_ip6 ? nm_ip6_config_get_mss (parent_ip6) : 0;
-		struct in6_addr int_gw = *nm_vpn_connection_get_ip6_internal_gateway (vpn);
+		const struct in6_addr *int_gw = nm_vpn_connection_get_ip6_internal_gateway (vpn);
 		int mss = nm_ip6_config_get_mss (ip6_config);
 
-		if (!nm_platform_ip6_route_add (ip_ifindex, in6addr_any, 0, int_gw, 0, mss)) {
+		if (!int_gw)
+			int_gw = &in6addr_any;
+		if (!nm_platform_ip6_route_add (ip_ifindex, in6addr_any, 0, *int_gw, 0, mss)) {
 			nm_platform_ip6_route_add (parent_ifindex, *gw_addr, 128, in6addr_any, 0, parent_mss);
-			if (!nm_platform_ip6_route_add (ip_ifindex, in6addr_any, 0, int_gw, 0, mss)) {
+			if (!nm_platform_ip6_route_add (ip_ifindex, in6addr_any, 0, *int_gw, 0, mss)) {
 				nm_log_err (LOGD_IP6 | LOGD_VPN, "Failed to set default route.");
 			}
 		}
-- 
1.8.3.1

_______________________________________________
networkmanager-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to