core: use ASSERT_VALID_PATH_COMPONENT

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller
2014-03-12 12:49:34 +01:00
parent ec7fc72e67
commit e739e01900
5 changed files with 20 additions and 7 deletions

View File

@@ -2153,6 +2153,8 @@ link_get_physical_port_id (NMPlatform *platform, int ifindex)
if (!ifname)
return NULL;
ifname = ASSERT_VALID_PATH_COMPONENT (ifname);
path = g_strdup_printf ("/sys/class/net/%s/phys_port_id", ifname);
id = sysctl_get (platform, path);
g_free (path);
@@ -2266,7 +2268,10 @@ link_option_path (int master, const char *category, const char *option)
if (!name || !category || !option)
return NULL;
return g_strdup_printf ("/sys/class/net/%s/%s/%s", name, category, option);
return g_strdup_printf ("/sys/class/net/%s/%s/%s",
ASSERT_VALID_PATH_COMPONENT (name),
ASSERT_VALID_PATH_COMPONENT (category),
ASSERT_VALID_PATH_COMPONENT (option));
}
static gboolean
@@ -2352,7 +2357,7 @@ infiniband_partition_add (NMPlatform *platform, int parent, int p_key)
parent_name = nm_platform_link_get_name (parent);
g_return_val_if_fail (parent_name != NULL, FALSE);
path = g_strdup_printf ("/sys/class/net/%s/create_child", parent_name);
path = g_strdup_printf ("/sys/class/net/%s/create_child", ASSERT_VALID_PATH_COMPONENT (parent_name));
id = g_strdup_printf ("0x%04x", p_key);
success = nm_platform_sysctl_set (path, id);
g_free (id);
@@ -2412,6 +2417,7 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
ifname = nm_platform_link_get_name (ifindex);
if (!ifname || !nm_utils_iface_valid_name (ifname))
return FALSE;
ifname = ASSERT_VALID_PATH_COMPONENT (ifname);
path = g_strdup_printf ("/sys/class/net/%s/owner", ifname);
val = nm_platform_sysctl_get (path);