]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
socket-util: extend the buffer in sockaddr_union to make it consistent with hw_addr_data
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 15 May 2026 22:18:37 +0000 (07:18 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 16 May 2026 13:33:40 +0000 (22:33 +0900)
Concerned by Claude:
https://github.com/systemd/systemd/pull/42119#discussion_r3251133516

src/basic/basic-forward.h
src/basic/ether-addr-util.h
src/basic/socket-util.c
src/basic/socket-util.h
src/libsystemd-network/lldp-network.c

index 396056a8e55ebe93aa1d5c90767b508bfe661dec..064af284a654cfb982ad6eabf0750984abd4619a 100644 (file)
@@ -153,3 +153,7 @@ typedef struct SocketAddress SocketAddress;
 
 /* MAX_ERRNO is defined as 4095 in linux/err.h. We use the same value here. */
 #define ERRNO_MAX               4095
+
+/* This is MAX_ADDR_LEN as defined in linux/netdevice.h, but net/if_arp.h
+ * defines a macro of the same name with a much lower size. */
+#define HW_ADDR_MAX_SIZE 32
index 1d6e4cda7f01681bfa34489627f5fb45a64e9c90..42b899e7ebc868c8245ac26b8f7492422f7a3d72 100644 (file)
@@ -7,10 +7,6 @@
 
 #include "basic-forward.h"
 
-/* This is MAX_ADDR_LEN as defined in linux/netdevice.h, but net/if_arp.h
- * defines a macro of the same name with a much lower size. */
-#define HW_ADDR_MAX_SIZE 32
-
 struct hw_addr_data {
         size_t length;
         union {
index d53208f1389909c4817cf5cfc1a4b1837ac634f8..d84537bf4413a4788df24c391b1810d140152b5d 100644 (file)
@@ -3,6 +3,8 @@
 #include <fcntl.h>
 #include <linux/if.h>
 #include <linux/if_arp.h>
+#include <linux/if_ether.h>
+#include <linux/if_infiniband.h>
 #include <linux/pkt_sched.h>
 #include <mqueue.h>
 #include <net/if.h>
index 208eb7ac077bed00c5166196522cf0c7fc935017..1703a518e48dee7fab6c57db8848eba83a83fa01 100644 (file)
@@ -1,8 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#include <linux/if_ether.h>
-#include <linux/if_infiniband.h>
 #include <linux/if_packet.h>
 #include <linux/netlink.h>
 #include <linux/vm_sockets.h>
@@ -29,8 +27,8 @@ union sockaddr_union {
         struct sockaddr_ll ll;
         struct sockaddr_vm vm;
 
-        /* Ensure there is enough space to store Infiniband addresses */
-        uint8_t ll_buffer[offsetof(struct sockaddr_ll, sll_addr) + CONST_MAX(ETH_ALEN, INFINIBAND_ALEN)];
+        /* Ensure there is enough space to store an arbitrary hardware address, e.g. Infiniband */
+        uint8_t ll_buffer[offsetof(struct sockaddr_ll, sll_addr) + HW_ADDR_MAX_SIZE];
 
         /* Ensure there is enough space after the AF_UNIX sun_path for one more NUL byte, just to be sure that the path
          * component is always followed by at least one NUL byte. */
index 53dd50c6068874f8dbe523077153575882c7a92d..f8185a28029bbe8c7055645be9b1794d02e4c6f8 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <linux/filter.h>
+#include <linux/if_ether.h>
 
 #include "fd-util.h"
 #include "lldp-network.h"