From fe88dcd8fec8445f793f973be7846b470a0d9280 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 24 Mar 2014 12:34:43 +0100 Subject: [PATCH] platform: relax assert when checking pathnames for accessing sysctl Asserting against "/.." is wrong, because one could rename a link to "..em1", which is a valid ifname but would crash NetworkManager. Signed-off-by: Thomas Haller --- src/platform/nm-linux-platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index edc8fe4143..defe7c92c8 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -1602,7 +1602,7 @@ sysctl_set (NMPlatform *platform, const char *path, const char *value) g_assert (g_str_has_prefix (path, "/proc/sys/") || g_str_has_prefix (path, "/sys/")); /* Don't write to suspicious locations */ - g_assert (!strstr (path, "/..")); + g_assert (!strstr (path, "/../")); fd = open (path, O_WRONLY | O_TRUNC); if (fd == -1) { @@ -1701,7 +1701,7 @@ sysctl_get (NMPlatform *platform, const char *path) g_assert (g_str_has_prefix (path, "/proc/sys/") || g_str_has_prefix (path, "/sys/")); /* Don't write to suspicious locations */ - g_assert (!strstr (path, "/..")); + g_assert (!strstr (path, "/../")); if (!g_file_get_contents (path, &contents, NULL, &error)) { /* We assume FAILED means EOPNOTSUP */