core: use ASSERT_VALID_PATH_COMPONENT
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
@@ -1046,6 +1046,9 @@ nm_utils_ip6_property_path (const char *ifname, const char *property)
|
||||
static char path[sizeof (IPV6_PROPERTY_DIR) + IFNAMSIZ + 32];
|
||||
int len;
|
||||
|
||||
ifname = ASSERT_VALID_PATH_COMPONENT (ifname);
|
||||
property = ASSERT_VALID_PATH_COMPONENT (property);
|
||||
|
||||
len = g_snprintf (path, sizeof (path), IPV6_PROPERTY_DIR "%s/%s",
|
||||
ifname, property);
|
||||
g_assert (len < sizeof (path) - 1);
|
||||
|
@@ -538,7 +538,8 @@ carrier_update_cb (gpointer user_data)
|
||||
|
||||
iface = nm_device_get_iface (NM_DEVICE (self));
|
||||
|
||||
path = g_strdup_printf ("/sys/class/atm/%s/carrier", iface);
|
||||
path = g_strdup_printf ("/sys/class/atm/%s/carrier",
|
||||
ASSERT_VALID_PATH_COMPONENT (iface));
|
||||
success = g_file_get_contents (path, &contents, NULL, &error);
|
||||
g_free (path);
|
||||
|
||||
@@ -581,7 +582,8 @@ get_atm_index (const char *iface, GError **error)
|
||||
char *path, *contents;
|
||||
int idx = -1;
|
||||
|
||||
path = g_strdup_printf ("/sys/class/atm/%s/atmindex", iface);
|
||||
path = g_strdup_printf ("/sys/class/atm/%s/atmindex",
|
||||
ASSERT_VALID_PATH_COMPONENT (iface));
|
||||
if (g_file_get_contents (path, &contents, NULL, error))
|
||||
idx = atoi (contents);
|
||||
g_free (path);
|
||||
|
@@ -168,7 +168,8 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
|
||||
|
||||
transport_mode = nm_setting_infiniband_get_transport_mode (s_infiniband);
|
||||
|
||||
mode_path = g_strdup_printf ("/sys/class/net/%s/mode", nm_device_get_iface (dev));
|
||||
mode_path = g_strdup_printf ("/sys/class/net/%s/mode",
|
||||
ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (dev)));
|
||||
if (!g_file_test (mode_path, G_FILE_TEST_EXISTS)) {
|
||||
g_free (mode_path);
|
||||
|
||||
@@ -327,7 +328,8 @@ update_connection (NMDevice *device, NMConnection *connection)
|
||||
g_byte_array_unref (array);
|
||||
}
|
||||
|
||||
mode_path = g_strdup_printf ("/sys/class/net/%s/mode", nm_device_get_iface (device));
|
||||
mode_path = g_strdup_printf ("/sys/class/net/%s/mode",
|
||||
ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (device)));
|
||||
if (g_file_get_contents (mode_path, &contents, NULL, NULL)) {
|
||||
if (strstr (contents, "datagram"))
|
||||
transport_mode = "datagram";
|
||||
|
@@ -331,7 +331,7 @@ constructor (GType type,
|
||||
* don't have to poll.
|
||||
*/
|
||||
priv->ipw_rfkill_path = g_strdup_printf ("/sys/class/net/%s/device/rf_kill",
|
||||
nm_device_get_iface (NM_DEVICE (self)));
|
||||
ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (NM_DEVICE (self))));
|
||||
if (!g_file_test (priv->ipw_rfkill_path, G_FILE_TEST_IS_REGULAR)) {
|
||||
g_free (priv->ipw_rfkill_path);
|
||||
priv->ipw_rfkill_path = NULL;
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user