1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-07 01:27:11 +03:00

networkd: avoid segfault

This commit is contained in:
Tom Gundersen 2013-11-21 20:47:34 +01:00
parent 94d56326a1
commit 602cc437e8

View File

@ -29,6 +29,7 @@
int link_new(Manager *manager, struct udev_device *device, Link **ret) {
_cleanup_link_free_ Link *link = NULL;
const char *mac;
struct ether_addr *mac_addr;
int r;
assert(device);
@ -46,7 +47,12 @@ int link_new(Manager *manager, struct udev_device *device, Link **ret) {
if (!mac)
return -EINVAL;
memcpy(&link->mac.ether_addr_octet[0], ether_aton(mac), ETH_ALEN);
mac_addr = ether_aton(mac);
if (!mac_addr)
return -EINVAL;
memcpy(&link->mac, mac_addr, sizeof(struct ether_addr));
link->manager = manager;
link->state = _LINK_STATE_INVALID;