Fix unaligned memory access when creating ICMP Port Unreachable messages

commit 3b69d09c80 corrected the
unreachable handling for net/udp/icmp but introduced an unaligned store.
This splits the uint32_t data field into a two element uint16_t data
field to avoid the unaligned store.
This commit is contained in:
Norman Rasmussen
2021-12-27 22:32:42 -08:00
committed by Xiang Xiao
parent 579738c8fa
commit 48311cc61f
4 changed files with 8 additions and 6 deletions
+2 -1
View File
@@ -153,7 +153,8 @@ void icmp_reply(FAR struct net_driver_s *dev, int type, int code)
icmp->type = type;
icmp->icode = code;
icmp->data = 0;
icmp->data[0] = 0;
icmp->data[1] = 0;
/* Calculate the ICMP checksum. */
+4 -3
View File
@@ -133,9 +133,10 @@ void icmpv6_reply(FAR struct net_driver_s *dev, int type, int code, int data)
/* Initialize the ICMPv6 header */
icmpv6->type = type;
icmpv6->code = code;
icmpv6->data = htonl(data);
icmpv6->type = type;
icmpv6->code = code;
icmpv6->data[0] = data >> 16;
icmpv6->data[1] = data & 0xffff;
/* Calculate the ICMPv6 checksum over the ICMPv6 header and payload. */