mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-10 11:40:18 +01:00
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.
This commit is contained in:
parent
7a838e0a91
commit
736d0a4a40
2 changed files with 11 additions and 8 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue