Commit 2b72214e authored by Jiří Klimeš's avatar Jiří Klimeš

platform: fix a crash when nm_platform_sysctl_get() returns NULL (rh #1010522)

nm_platform_sysctl_get() can return NULL on an error (when file specified by
'path' argument doesn't exist, can't be opened, etc.)

https://bugzilla.redhat.com/show_bug.cgi?id=1010522
parent 28530239
......@@ -1946,12 +1946,16 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
path = g_strdup_printf ("/sys/class/net/%s/group", ifname);
val = nm_platform_sysctl_get (path);
g_free (path);
if (!val)
return FALSE;
props->group = strtoll (val, NULL, 10);
g_free (val);
path = g_strdup_printf ("/sys/class/net/%s/tun_flags", ifname);
val = nm_platform_sysctl_get (path);
g_free (path);
if (!val)
return FALSE;
flags = strtoul (val, NULL, 16);
props->mode = ((flags & TUN_TYPE_MASK) == TUN_TUN_DEV) ? "tun" : "tap";
props->no_pi = !!(flags & IFF_NO_PI);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment