diff options
author | Thomas Haller <thaller@redhat.com> | 2016-02-17 13:25:34 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-02-17 13:39:55 +0100 |
commit | c205ee6ce08ceb7bdf4ed366d07c74e57b7ab691 (patch) | |
tree | c946c749590fc62563140c017457c7fcf788ef36 | |
parent | 06857805664153407d25b50f0412009ab7800a0a (diff) | |
download | NetworkManager-c205ee6ce08ceb7bdf4ed366d07c74e57b7ab691.tar.gz |
platform: stack-allocate temporary string in nm_platform_link_tun_get_properties_ifname()
-rw-r--r-- | src/platform/nm-platform.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 85e22989f9..e7a8b78fc5 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -2134,7 +2134,8 @@ nm_platform_link_veth_get_properties (NMPlatform *self, int ifindex, int *out_pe gboolean nm_platform_link_tun_get_properties_ifname (NMPlatform *self, const char *ifname, NMPlatformTunProperties *props) { - char *path, *val; + char path[256]; + char *val; gboolean success = TRUE; _CHECK_SELF (self, klass, FALSE); @@ -2147,11 +2148,9 @@ nm_platform_link_tun_get_properties_ifname (NMPlatform *self, const char *ifname 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); + nm_sprintf_buf (path, "/sys/class/net/%s/owner", ifname); val = nm_platform_sysctl_get (self, path); - g_free (path); if (val) { props->owner = _nm_utils_ascii_str_to_int64 (val, 10, -1, G_MAXINT64, -1); if (errno) @@ -2160,9 +2159,8 @@ nm_platform_link_tun_get_properties_ifname (NMPlatform *self, const char *ifname } else success = FALSE; - path = g_strdup_printf ("/sys/class/net/%s/group", ifname); + nm_sprintf_buf (path, "/sys/class/net/%s/group", ifname); val = nm_platform_sysctl_get (self, path); - g_free (path); if (val) { props->group = _nm_utils_ascii_str_to_int64 (val, 10, -1, G_MAXINT64, -1); if (errno) @@ -2171,9 +2169,8 @@ nm_platform_link_tun_get_properties_ifname (NMPlatform *self, const char *ifname } else success = FALSE; - path = g_strdup_printf ("/sys/class/net/%s/tun_flags", ifname); + nm_sprintf_buf (path, "/sys/class/net/%s/tun_flags", ifname); val = nm_platform_sysctl_get (self, path); - g_free (path); if (val) { gint64 flags; |