diff options
author | Dan Winship <danw@gnome.org> | 2014-04-01 15:05:29 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-04-01 15:07:49 -0400 |
commit | 736d0a4a401b3919cd5215908e166cd84798f8e2 (patch) | |
tree | fd3bbb4ebd901997eb40b2df37de0120c4f36a14 | |
parent | 7a838e0a916933e0133b22ad3137254c4550faec (diff) | |
download | NetworkManager-736d0a4a401b3919cd5215908e166cd84798f8e2.tar.gz |
ifcfg-rh: fix bugs in the new alias code (rh #1067170)
Fix a bug when reading an invalid alias file, where the code meant to
skip the rest of the loop iteration, but failed.
Also fix a memory leak and remove an unused variable.
Bugs noticed by coverity.
-rw-r--r-- | src/settings/plugins/ifcfg-rh/reader.c | 16 | ||||
-rw-r--r-- | src/settings/plugins/ifcfg-rh/writer.c | 3 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index 65142b92f5..70e58e9e03 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -1381,8 +1381,10 @@ make_ip4_setting (shvarFile *ifcfg, NMIP4Address *addr = NULL; addr = nm_ip4_address_new (); - if (!read_full_ip4_address (ifcfg, network_file, i, addr, error)) + if (!read_full_ip4_address (ifcfg, network_file, i, addr, error)) { + nm_ip4_address_unref (addr); goto done; + } if (!nm_ip4_address_get_address (addr)) { nm_ip4_address_unref (addr); @@ -1551,11 +1553,13 @@ read_aliases (NMSettingIP4Config *s_ip4, const char *filename, const char *netwo p = strchr (item, ':'); g_assert (p != NULL); /* we know this is true from utils_is_ifcfg_alias_file() */ for (p++; *p; p++) { - if (!g_ascii_isalnum (*p) && *p != '_') { - PLUGIN_WARN (IFCFG_PLUGIN_NAME, " alias: ignoring alias file '%s' with invalid name", full_path); - g_free (full_path); - continue; - } + if (!g_ascii_isalnum (*p) && *p != '_') + break; + } + if (*p) { + PLUGIN_WARN (IFCFG_PLUGIN_NAME, " alias: ignoring alias file '%s' with invalid name", full_path); + g_free (full_path); + continue; } parsed = svNewFile (full_path); diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index 720616d1d5..5e962c57cd 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -2146,10 +2146,9 @@ write_ip4_aliases (NMConnection *connection, char *base_ifcfg_path) { NMSettingIP4Config *s_ip4; char *base_ifcfg_dir, *base_ifcfg_name, *base_name; - int i, num, base_ifcfg_path_len, base_ifcfg_name_len, base_name_len; + int i, num, base_ifcfg_name_len, base_name_len; GDir *dir; - base_ifcfg_path_len = strlen (base_ifcfg_path); base_ifcfg_dir = g_path_get_dirname (base_ifcfg_path); base_ifcfg_name = g_path_get_basename (base_ifcfg_path); base_ifcfg_name_len = strlen (base_ifcfg_name); |