summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-11-21 20:47:34 +0100
committerTom Gundersen <teg@jklm.no>2013-11-21 20:48:06 +0100
commit602cc437e8b4a3ab760b5a23fa4f3112134d9c36 (patch)
tree7f1465324579eed454b789a08199ae850abafeb6 /src/network
parent94d56326a1cb337151ea0984d5b86f6edc005bce (diff)
networkd: avoid segfault
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-link.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index d41fe80f20..c03472216c 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -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;