]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
libsystemd-network: add comment explaining unusual memory access
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 10 Nov 2020 14:33:28 +0000 (15:33 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 10 Nov 2020 14:52:32 +0000 (15:52 +0100)
Inspired by coverity CID#1435984. I'm confused by the union definion every time I look at it...
Let's at least add a comment to help future readers.

src/libsystemd-network/dhcp-network.c

index 6c82d5508ec242ea6b66a170c1b2bc5096dad52f..656482bf83810a82f8d34f01639f7e5f39d45714 100644 (file)
@@ -106,7 +106,7 @@ static int _bind_raw_socket(int ifindex, union sockaddr_union *link,
                 .sll_hatype = htobe16(arp_type),
                 .sll_halen = bcast_addr_len,
         };
-        memcpy(link->ll.sll_addr, bcast_addr, bcast_addr_len);
+        memcpy(link->ll.sll_addr, bcast_addr, bcast_addr_len); /* We may overflow link->ll. link->ll_buffer ensures we have enough space. */
 
         r = bind(s, &link->sa, SOCKADDR_LL_LEN(link->ll));
         if (r < 0)