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>
This commit is contained in:
parent
a1d916edd0
commit
35a10937d7
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user