mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
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:
committed by
Xiang Xiao
parent
579738c8fa
commit
48311cc61f
@@ -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. */
|
||||
|
||||
|
||||
@@ -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. */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user