Blame SOURCES/rh1067170-alias-fix.patch

94180d
From 736d0a4a401b3919cd5215908e166cd84798f8e2 Mon Sep 17 00:00:00 2001
94180d
From: Dan Winship <danw@gnome.org>
94180d
Date: Tue, 1 Apr 2014 15:05:29 -0400
94180d
Subject: [PATCH] ifcfg-rh: fix bugs in the new alias code (rh #1067170)
94180d
94180d
Fix a bug when reading an invalid alias file, where the code meant to
94180d
skip the rest of the loop iteration, but failed.
94180d
94180d
Also fix a memory leak and remove an unused variable.
94180d
94180d
Bugs noticed by coverity.
94180d
---
94180d
 src/settings/plugins/ifcfg-rh/reader.c | 16 ++++++++++------
94180d
 src/settings/plugins/ifcfg-rh/writer.c |  3 +--
94180d
 2 files changed, 11 insertions(+), 8 deletions(-)
94180d
94180d
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c
94180d
index 65142b9..70e58e9 100644
94180d
--- a/src/settings/plugins/ifcfg-rh/reader.c
94180d
+++ b/src/settings/plugins/ifcfg-rh/reader.c
94180d
@@ -1381,8 +1381,10 @@ make_ip4_setting (shvarFile *ifcfg,
94180d
 		NMIP4Address *addr = NULL;
94180d
 
94180d
 		addr = nm_ip4_address_new ();
94180d
-		if (!read_full_ip4_address (ifcfg, network_file, i, addr, error))
94180d
+		if (!read_full_ip4_address (ifcfg, network_file, i, addr, error)) {
94180d
+			nm_ip4_address_unref (addr);
94180d
 			goto done;
94180d
+		}
94180d
 		if (!nm_ip4_address_get_address (addr)) {
94180d
 			nm_ip4_address_unref (addr);
94180d
 
94180d
@@ -1551,11 +1553,13 @@ read_aliases (NMSettingIP4Config *s_ip4, const char *filename, const char *netwo
94180d
 			p = strchr (item, ':');
94180d
 			g_assert (p != NULL); /* we know this is true from utils_is_ifcfg_alias_file() */
94180d
 			for (p++; *p; p++) {
94180d
-				if (!g_ascii_isalnum (*p) && *p != '_') {
94180d
-					PLUGIN_WARN (IFCFG_PLUGIN_NAME, "    alias: ignoring alias file '%s' with invalid name", full_path);
94180d
-					g_free (full_path);
94180d
-					continue;
94180d
-				}
94180d
+				if (!g_ascii_isalnum (*p) && *p != '_')
94180d
+					break;
94180d
+			}
94180d
+			if (*p) {
94180d
+				PLUGIN_WARN (IFCFG_PLUGIN_NAME, "    alias: ignoring alias file '%s' with invalid name", full_path);
94180d
+				g_free (full_path);
94180d
+				continue;
94180d
 			}
94180d
 
94180d
 			parsed = svNewFile (full_path);
94180d
diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c
94180d
index 720616d..5e962c5 100644
94180d
--- a/src/settings/plugins/ifcfg-rh/writer.c
94180d
+++ b/src/settings/plugins/ifcfg-rh/writer.c
94180d
@@ -2146,10 +2146,9 @@ write_ip4_aliases (NMConnection *connection, char *base_ifcfg_path)
94180d
 {
94180d
 	NMSettingIP4Config *s_ip4;
94180d
 	char *base_ifcfg_dir, *base_ifcfg_name, *base_name;
94180d
-	int i, num, base_ifcfg_path_len, base_ifcfg_name_len, base_name_len;
94180d
+	int i, num, base_ifcfg_name_len, base_name_len;
94180d
 	GDir *dir;
94180d
 
94180d
-	base_ifcfg_path_len = strlen (base_ifcfg_path);
94180d
 	base_ifcfg_dir = g_path_get_dirname (base_ifcfg_path);
94180d
 	base_ifcfg_name = g_path_get_basename (base_ifcfg_path);
94180d
 	base_ifcfg_name_len = strlen (base_ifcfg_name);
94180d
-- 
94180d
1.8.5.3
94180d