Check return value of udev_device_get_sysattr_value(); before using atoi();
authorShinwoo Kim <cinoo.kim@samsung.com>
Sat, 29 Nov 2014 06:53:24 +0000 (15:53 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Sat, 29 Nov 2014 06:53:24 +0000 (15:53 +0900)
Summary: udev_device_get_sysattr_value(); could return NULL, and using atoi(); with NULL make system crash

Test Plan: It is hard to make a case to retun NULL. I got this from aging test of a product.

Reviewers: cedric, raster, seoz, woohyun, Hermet, jaehwan

Subscribers: cedric, seoz

Differential Revision: https://phab.enlightenment.org/D1687

src/lib/eeze/eeze_net.c

index 044c899..8c6b386 100644 (file)
@@ -84,6 +84,15 @@ eeze_net_new(const char *name)
    net->syspath = syspath;
    net->name = eina_stringshare_add(name);
    idx = udev_device_get_sysattr_value(net->device, "ifindex");
+   if (!idx)
+     {
+        udev_device_unref(net->device);
+        eina_stringshare_del(net->syspath);
+        eina_stringshare_del(net->name);
+
+        free(net);
+        return NULL;
+     }
    net->index = atoi(idx);
    eina_hash_add(eeze_nets, name, net);
    udev_enumerate_unref(en);