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
This commit is contained in:
Jiří Klimeš 2013-09-23 18:19:16 +02:00
parent 28530239fa
commit 2b72214e52

View file

@ -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);