Commit 736d0a4a authored by Dan Winship's avatar Dan Winship
Browse files

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.
parent 7a838e0a
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment