Fix strict aliasing violation in inet_checksum()
authorMaciej S. Szmigiero <mail@maciej.szmigiero.name>
Tue, 16 Apr 2019 13:00:50 +0000 (15:00 +0200)
committerMaciej S. Szmigiero <mail@maciej.szmigiero.name>
Tue, 16 Apr 2019 13:01:22 +0000 (15:01 +0200)
inet_checksum() accesses packet data as an array of uint16_t, but the
packet data can be for example of "anonymous struct pseudo" type from
route_ipv6_unreachable().
This type isn't a compatible type with uint16_t so a strict aliasing
violation occurs and causes the checksum to be computed incorrectly.

Fix this by using the memcpy() idiom to read the packet data as an array of
uint16_t in inet_checksum() (this should be understood by compilers and
optimized accordingly, so no actual copy occurs).


No differences found