]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP: Align the BPF buffer to sizeof(struct ip *)
authorRoy Marples <roy@marples.name>
Wed, 12 Feb 2025 12:02:53 +0000 (12:02 +0000)
committerRoy Marples <roy@marples.name>
Wed, 12 Feb 2025 12:02:53 +0000 (12:02 +0000)
This is for non privsep only and should fix Sparc64.
Fixes #430.

src/dhcp.c

index d521e2014e942fcb5a5474b5eac0ec963c3ef257..504e013180f882154cf17e5ff953ac8abf6561bd 100644 (file)
@@ -49,6 +49,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <inttypes.h>
+#include <stdalign.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdio.h>
@@ -3715,7 +3716,8 @@ static void
 dhcp_readbpf(void *arg, unsigned short events)
 {
        struct interface *ifp = arg;
-       uint8_t buf[FRAMELEN_MAX];
+       /* Sparc64 needs this buffer aligned */
+       alignas(sizeof(struct ip *)) uint8_t buf[FRAMELEN_MAX];
        ssize_t bytes;
        struct dhcp_state *state = D_STATE(ifp);
        struct bpf *bpf = state->bpf;