Re: crashing vpn properties (patch)



Casey Harkins wrote:
Actually, whenever anything stuffs stuff into that table it needs to
g_strdup() the key.  See update_one_secret() and copy_hash().
Otherwise, you'll leak the keys when freeing the hash.  So anything that
uses NMSettingVPNProperties (like the properties dialogs) also need to
g_strdup() the key.  I probably missed that when fixing up the VPN
properties hash.


Makes sense. Attached is a patch fixing this for the openvpn properties dialog. I'll take a look at the other vpn plugins as well (I know vpnc was crashing in my limited testing as well).


And here's an untested patch for vpnc. A brief look at the pptp plugin looks like it hasn't been converted for the new API.

-casey

Index: vpn-daemons/vpnc/properties/nm-vpnc.c
===================================================================
--- vpn-daemons/vpnc/properties/nm-vpnc.c	(revision 3160)
+++ vpn-daemons/vpnc/properties/nm-vpnc.c	(working copy)
@@ -217,19 +217,19 @@
 	if (s_vpn_props->data)
 		g_hash_table_remove_all (s_vpn_props->data);
 
-	g_hash_table_insert (s_vpn_props->data, NM_VPNC_KEY_GATEWAY, str_to_gvalue (gateway));
-	g_hash_table_insert (s_vpn_props->data, NM_VPNC_KEY_ID, str_to_gvalue (groupname));
+	g_hash_table_insert (s_vpn_props->data, g_strdup(NM_VPNC_KEY_GATEWAY), str_to_gvalue (gateway));
+	g_hash_table_insert (s_vpn_props->data, g_strdup(NM_VPNC_KEY_ID), str_to_gvalue (groupname));
 
 	if (use_alternate_username)
-		g_hash_table_insert (s_vpn_props->data, NM_VPNC_KEY_XAUTH_USER, str_to_gvalue (username));
+		g_hash_table_insert (s_vpn_props->data, g_strdup(NM_VPNC_KEY_XAUTH_USER), str_to_gvalue (username));
 	if (use_domain)
-		g_hash_table_insert (s_vpn_props->data, NM_VPNC_KEY_DOMAIN, str_to_gvalue (domain));
+		g_hash_table_insert (s_vpn_props->data, g_strdup(NM_VPNC_KEY_DOMAIN), str_to_gvalue (domain));
 	if (use_keepalive)
-		g_hash_table_insert (s_vpn_props->data, NM_VPNC_KEY_NAT_KEEPALIVE, str_to_gvalue (keepalive));
+		g_hash_table_insert (s_vpn_props->data, g_strdup(NM_VPNC_KEY_NAT_KEEPALIVE), str_to_gvalue (keepalive));
 	if (enable_singledes)
-		g_hash_table_insert (s_vpn_props->data, NM_VPNC_KEY_SINGLE_DES, bool_to_gvalue (TRUE));
+		g_hash_table_insert (s_vpn_props->data, g_strdup(NM_VPNC_KEY_SINGLE_DES), bool_to_gvalue (TRUE));
 	if (disable_natt)
-		g_hash_table_insert (s_vpn_props->data, NM_VPNC_KEY_DISABLE_NAT, bool_to_gvalue (TRUE));
+		g_hash_table_insert (s_vpn_props->data, g_strdup(NM_VPNC_KEY_DISABLE_NAT), bool_to_gvalue (TRUE));
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]