Skip to content

Commit 35a1093

Browse files
aescolardanieldegrasse
authored andcommitted
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 <alberto.escolar.piedras@nordicsemi.no>
1 parent a1d916e commit 35a1093

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/net/dhcpv6/src/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ static void generate_fake_server_duid(void)
109109

110110
memset(serverid, 0, sizeof(*serverid));
111111

112-
UNALIGNED_PUT(htons(DHCPV6_DUID_TYPE_LL), &serverid->duid.type);
113-
UNALIGNED_PUT(htons(DHCPV6_HARDWARE_ETHERNET_TYPE), &duid_ll->hw_type);
112+
UNALIGNED_PUT(htons(DHCPV6_DUID_TYPE_LL),
113+
UNALIGNED_MEMBER_ADDR(serverid, duid.type));
114+
UNALIGNED_PUT(htons(DHCPV6_HARDWARE_ETHERNET_TYPE),
115+
UNALIGNED_MEMBER_ADDR(duid_ll, hw_type));
114116
memcpy(duid_ll->ll_addr, fake_mac, sizeof(fake_mac));
115117

116118
serverid->length = DHCPV6_DUID_LL_HEADER_SIZE + sizeof(fake_mac);

0 commit comments

Comments
 (0)