From f19e79cd7a739a20940597c1e373083e8837f411 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 15 Apr 2014 19:17:22 +0200 Subject: [PATCH 1/4] core: fix potential crash in nm-dhcp-client Error found by coverity. https://bugzilla.gnome.org/show_bug.cgi?id=728320 Signed-off-by: Thomas Haller --- src/dhcp-manager/nm-dhcp-dhclient.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dhcp-manager/nm-dhcp-dhclient.c b/src/dhcp-manager/nm-dhcp-dhclient.c index 9874074fb1..4232ee0cce 100644 --- a/src/dhcp-manager/nm-dhcp-dhclient.c +++ b/src/dhcp-manager/nm-dhcp-dhclient.c @@ -559,13 +559,13 @@ get_duid (NMDHCPClient *client) if (leasefile) { nm_log_dbg (LOGD_DHCP, "Looking for DHCPv6 DUID in '%s'.", leasefile); duid = nm_dhcp_dhclient_read_duid (leasefile, &error); - g_free (leasefile); if (error) { nm_log_warn (LOGD_DHCP, "Failed to read leasefile '%s': (%d) %s", leasefile, error->code, error->message); g_clear_error (&error); } + g_free (leasefile); } if (!duid && priv->def_leasefile) { From 73d4edb0b788f6534ef1d818492a1c06477ce044 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 15 Apr 2014 19:19:08 +0200 Subject: [PATCH 2/4] core: fix leaks for nm_setting_ip[46]_config_add_\(route\|address\)() Error found by coverity. https://bugzilla.gnome.org/show_bug.cgi?id=728320 Signed-off-by: Thomas Haller --- src/nm-ip6-config.c | 4 +++- src/settings/plugins/ifupdown/parser.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index 36f5e72fdc..0a7cf26a3b 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -540,7 +540,7 @@ nm_ip6_config_update_setting (const NMIP6Config *config, NMSettingIP6Config *set /* Routes */ for (i = 0; i < nroutes; i++) { const NMPlatformIP6Route *route = nm_ip6_config_get_route (config, i); - NMIP6Route *s_route = nm_ip6_route_new (); + NMIP6Route *s_route; /* Ignore link-local route. */ if (IN6_IS_ADDR_LINKLOCAL (&route->network)) @@ -550,6 +550,7 @@ nm_ip6_config_update_setting (const NMIP6Config *config, NMSettingIP6Config *set if (!route->plen) continue; + s_route = nm_ip6_route_new (); nm_ip6_route_set_dest (s_route, &route->network); nm_ip6_route_set_prefix (s_route, route->plen); if (!IN6_IS_ADDR_UNSPECIFIED (&route->network)) @@ -557,6 +558,7 @@ nm_ip6_config_update_setting (const NMIP6Config *config, NMSettingIP6Config *set nm_ip6_route_set_metric (s_route, route->metric); nm_setting_ip6_config_add_route (setting, s_route); + nm_ip6_route_unref (s_route); } /* DNS */ diff --git a/src/settings/plugins/ifupdown/parser.c b/src/settings/plugins/ifupdown/parser.c index 2b273bc3a2..91ed3e21ba 100644 --- a/src/settings/plugins/ifupdown/parser.c +++ b/src/settings/plugins/ifupdown/parser.c @@ -527,6 +527,7 @@ update_ip4_setting_from_if_block(NMConnection *connection, } else { nm_log_info (LOGD_SETTINGS, "ignoring duplicate IP4 address"); } + nm_ip4_address_unref (addr); nameserver_v = ifparser_getkey (block, "dns-nameserver"); ifupdown_ip4_add_dns (s_ip4, nameserver_v); @@ -647,6 +648,7 @@ update_ip6_setting_from_if_block(NMConnection *connection, } else { nm_log_info (LOGD_SETTINGS, "ignoring duplicate IP6 address"); } + nm_ip6_address_unref (addr); nameserver_v = ifparser_getkey(block, "dns-nameserver"); ifupdown_ip6_add_dns (s_ip6, nameserver_v); From 628e774ba84af1b28a9f1f872b6aa55c11bfaa2e Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 15 Apr 2014 19:32:48 +0200 Subject: [PATCH 3/4] ifcfg-rh: fix crash for reading invalid bridge configuration Error found by coverity. https://bugzilla.gnome.org/show_bug.cgi?id=728320 Signed-off-by: Thomas Haller --- src/settings/plugins/ifcfg-rh/reader.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index 57e07ef4dc..be480d8616 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -215,17 +215,16 @@ make_connection_setting (const char *file, value = svGetValue (ifcfg, "BRIDGE", FALSE); if (value) { - const char *bridge; + const char *old_value; - if ((bridge = nm_setting_connection_get_master (s_con))) { + if ((old_value = nm_setting_connection_get_master (s_con))) { PARSE_WARNING ("Already configured as slave of %s. Ignoring BRIDGE=\"%s\"", - bridge, value); - g_free (value); + old_value, value); + } else { + g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, value, NULL); + g_object_set (s_con, NM_SETTING_CONNECTION_SLAVE_TYPE, + NM_SETTING_BRIDGE_SETTING_NAME, NULL); } - - g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, value, NULL); - g_object_set (s_con, NM_SETTING_CONNECTION_SLAVE_TYPE, - NM_SETTING_BRIDGE_SETTING_NAME, NULL); g_free (value); } From cf96ced717198ee666318b342c7d036881666239 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 15 Apr 2014 19:34:03 +0200 Subject: [PATCH 4/4] ifcfg-rh: fix leak in svOpenFileInternal() Error found by coverity. https://bugzilla.gnome.org/show_bug.cgi?id=728320 Signed-off-by: Thomas Haller --- src/settings/plugins/ifcfg-rh/shvar.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index 1c670fe2f3..4e8e29ce59 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -79,6 +79,7 @@ svOpenFileInternal (const char *name, gboolean create, GError **error) continue; if (nread <= 0) { errsv = errno; + g_free (arena); goto bail; } total += nread;