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:
parent
579738c8fa
commit
48311cc61f
@ -141,7 +141,7 @@ struct icmp_hdr_s
|
|||||||
uint16_t seqno; /* " " "" " " " " " " " " */
|
uint16_t seqno; /* " " "" " " " " " " " " */
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t data;
|
uint16_t data[2];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ struct icmpv6_hdr_s
|
|||||||
* message type indicated by the Type and Code fields.
|
* message type indicated by the Type and Code fields.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint32_t data;
|
uint16_t data[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The ICMPv6 and IPv6 headers */
|
/* The ICMPv6 and IPv6 headers */
|
||||||
|
@ -153,7 +153,8 @@ void icmp_reply(FAR struct net_driver_s *dev, int type, int code)
|
|||||||
|
|
||||||
icmp->type = type;
|
icmp->type = type;
|
||||||
icmp->icode = code;
|
icmp->icode = code;
|
||||||
icmp->data = 0;
|
icmp->data[0] = 0;
|
||||||
|
icmp->data[1] = 0;
|
||||||
|
|
||||||
/* Calculate the ICMP checksum. */
|
/* 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 */
|
/* Initialize the ICMPv6 header */
|
||||||
|
|
||||||
icmpv6->type = type;
|
icmpv6->type = type;
|
||||||
icmpv6->code = code;
|
icmpv6->code = code;
|
||||||
icmpv6->data = htonl(data);
|
icmpv6->data[0] = data >> 16;
|
||||||
|
icmpv6->data[1] = data & 0xffff;
|
||||||
|
|
||||||
/* Calculate the ICMPv6 checksum over the ICMPv6 header and payload. */
|
/* Calculate the ICMPv6 checksum over the ICMPv6 header and payload. */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user