From 35a10937d749cbaffcd4eb8751bd0394abc185b2 Mon Sep 17 00:00:00 2001 From: Alberto Escolar Piedras Date: Tue, 1 Jul 2025 15:47:35 +0200 Subject: [PATCH] tests/net: dhcpv6: Avoid directly accessing address of unaligned struct Use UNALIGNED_MEMBER_ADDR when getting the address of possibly unaligned structures members instead of attempting to directly get the address as an offset. Signed-off-by: Alberto Escolar Piedras --- tests/net/dhcpv6/src/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/net/dhcpv6/src/main.c b/tests/net/dhcpv6/src/main.c index b1375383c67..a7c396cc078 100644 --- a/tests/net/dhcpv6/src/main.c +++ b/tests/net/dhcpv6/src/main.c @@ -109,8 +109,10 @@ static void generate_fake_server_duid(void) memset(serverid, 0, sizeof(*serverid)); - UNALIGNED_PUT(htons(DHCPV6_DUID_TYPE_LL), &serverid->duid.type); - UNALIGNED_PUT(htons(DHCPV6_HARDWARE_ETHERNET_TYPE), &duid_ll->hw_type); + UNALIGNED_PUT(htons(DHCPV6_DUID_TYPE_LL), + UNALIGNED_MEMBER_ADDR(serverid, duid.type)); + UNALIGNED_PUT(htons(DHCPV6_HARDWARE_ETHERNET_TYPE), + UNALIGNED_MEMBER_ADDR(duid_ll, hw_type)); memcpy(duid_ll->ll_addr, fake_mac, sizeof(fake_mac)); serverid->length = DHCPV6_DUID_LL_HEADER_SIZE + sizeof(fake_mac);