From 855e4838f5a91cc9182c2432dcd0f530978912dc Mon Sep 17 00:00:00 2001 From: Nikolay Martynov <(none)> Date: Mon, 7 Mar 2016 00:57:23 -0500 Subject: [PATCH] Remove dns VPN/DEVICE DNS config before adding different one It turnes out that 'nm_dns_manager_add_ip{4,6}_config' can be called to add VPN/DEVICE config for device that already has one. On this case old config gets overwritten in 'priv->ip{4,6}_{vpn,device}_config' but is not removed from 'priv->configs'. The result of that is that old config still being applyed but is treated as 'other' config. Apart from being a slight memory leak this has user facing consequences: if old config was a split DNS VPN config 'split DNS' part will no longer work and those DNS servers will be used as 'global' DNS servers. This patch addresses the problem by making sure old values in 'priv->ip{4,6}_{vpn,device}_config' are removed from 'priv->configs' before new values are applyed. Signed-off-by: Nikolay Martynov --- src/dns-manager/nm-dns-manager.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c index 79d345b..eb4bab1 100644 --- a/src/dns-manager/nm-dns-manager.c +++ b/src/dns-manager/nm-dns-manager.c @@ -1094,9 +1094,17 @@ nm_dns_manager_add_ip4_config (NMDnsManager *self, switch (cfg_type) { case NM_DNS_IP_CONFIG_TYPE_VPN: + if (priv->ip4_vpn_config && priv->ip4_vpn_config != config) { + priv->configs = g_slist_remove (priv->configs, priv->ip4_vpn_config); + g_object_unref (priv->ip4_vpn_config); + } priv->ip4_vpn_config = config; break; case NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE: + if (priv->ip4_device_config && priv->ip4_device_config != config) { + priv->configs = g_slist_remove (priv->configs, priv->ip4_device_config); + g_object_unref (priv->ip4_device_config); + } priv->ip4_device_config = config; break; default: @@ -1167,9 +1175,17 @@ nm_dns_manager_add_ip6_config (NMDnsManager *self, switch (cfg_type) { case NM_DNS_IP_CONFIG_TYPE_VPN: + if (priv->ip6_vpn_config && priv->ip6_vpn_config != config) { + priv->configs = g_slist_remove (priv->configs, priv->ip6_vpn_config); + g_object_unref (priv->ip6_vpn_config); + } priv->ip6_vpn_config = config; break; case NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE: + if (priv->ip6_device_config && priv->ip6_device_config != config) { + priv->configs = g_slist_remove (priv->configs, priv->ip6_device_config); + g_object_unref (priv->ip6_device_config); + } priv->ip6_device_config = config; break; default: -- 2.7.2