diff options
author | bengal <bengal@users.noreply.github.com> | 2017-08-08 18:55:31 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-08-08 18:55:31 +0200 |
commit | b1f24b75af135fe8efba9c7264447985e2843511 (patch) | |
tree | 6d9f0f2ba4c0b05c1f2ce1d6c913d94080ce0181 /src/libsystemd-network/dhcp-network.c | |
parent | ed88a9007a9e45e31d9100c965ab3f94370ec801 (diff) | |
download | systemd-b1f24b75af135fe8efba9c7264447985e2843511.tar.gz systemd-b1f24b75af135fe8efba9c7264447985e2843511.tar.bz2 systemd-b1f24b75af135fe8efba9c7264447985e2843511.zip |
dhcp-network: adjust sockaddr length for addresses longer than 8 bytes (#6527)
An infiniband hardware address is 20 bytes, but sockaddr_ll.sll_addr is only 8
bytes. Explicitly ensure that sockaddr_union has enough space for infiniband
addresses, even if they run over sockaddr_ll and add a macro to compute the
proper size to pass to kernel.
Diffstat (limited to 'src/libsystemd-network/dhcp-network.c')
-rw-r--r-- | src/libsystemd-network/dhcp-network.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/libsystemd-network/dhcp-network.c b/src/libsystemd-network/dhcp-network.c index 65405dcce0..a440a20f96 100644 --- a/src/libsystemd-network/dhcp-network.c +++ b/src/libsystemd-network/dhcp-network.c @@ -108,14 +108,16 @@ static int _bind_raw_socket(int ifindex, union sockaddr_union *link, if (r < 0) return -errno; - link->ll.sll_family = AF_PACKET; - link->ll.sll_protocol = htobe16(ETH_P_IP); - link->ll.sll_ifindex = ifindex; - link->ll.sll_hatype = htobe16(arp_type); - link->ll.sll_halen = mac_addr_len; + link->ll = (struct sockaddr_ll) { + .sll_family = AF_PACKET, + .sll_protocol = htobe16(ETH_P_IP), + .sll_ifindex = ifindex, + .sll_hatype = htobe16(arp_type), + .sll_halen = mac_addr_len, + }; memcpy(link->ll.sll_addr, bcast_addr, mac_addr_len); - r = bind(s, &link->sa, sizeof(link->ll)); + r = bind(s, &link->sa, SOCKADDR_LL_LEN(link->ll)); if (r < 0) return -errno; @@ -221,7 +223,7 @@ int dhcp_network_send_raw_socket(int s, const union sockaddr_union *link, assert(packet); assert(len); - r = sendto(s, packet, len, 0, &link->sa, sizeof(link->ll)); + r = sendto(s, packet, len, 0, &link->sa, SOCKADDR_LL_LEN(link->ll)); if (r < 0) return -errno; |