From a15ec56e4f947e098b7d841d8bc98c66717b4134 Mon Sep 17 00:00:00 2001 From: Shinwoo Kim Date: Sat, 29 Nov 2014 15:53:24 +0900 Subject: [PATCH] Check return value of udev_device_get_sysattr_value(); before using atoi(); 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib/eeze/eeze_net.c b/src/lib/eeze/eeze_net.c index 044c899..8c6b386 100644 --- a/src/lib/eeze/eeze_net.c +++ b/src/lib/eeze/eeze_net.c @@ -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); -- 2.7.4