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
This commit is contained in:
Shinwoo Kim 2014-11-29 15:53:24 +09:00 committed by Carsten Haitzler (Rasterman)
parent ac7d7c9cbe
commit a15ec56e4f
1 changed files with 9 additions and 0 deletions

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