ctdb-common: Fix aliasing issue in IPv6 checksum
authorMartin Schwenke <martin@meltin.net>
Mon, 13 Aug 2018 02:18:51 +0000 (12:18 +1000)
committerKarolin Seeger <kseeger@samba.org>
Tue, 28 Aug 2018 08:59:15 +0000 (10:59 +0200)
commit7e38e9503a28c6bf6314f84b28d89a15d23e524d
treeb71577faa982265a2445151ce23d0df0f2bfa6b3
parent3fd839aeba4ab5fe70837c16ff5320c0e1d132fa
ctdb-common: Fix aliasing issue in IPv6 checksum

Since commit 9c51b278b1700cd5f3e2addc19b7c711cc2ea10b the compiler has
been able to inline the affected call to uint16_checksum().  Given
that the data (phdr) is being accessed by an incompatible
pointer (data) there is an aliasing problem when the call is inlined.
This results in incorrect behaviour with -O2/-O3 when compiling with
at least GCC 6, 7, and 8.

Fix this by making the types compatible.

Also fixes CID 1437604 (Reliance on integer endianness).  This is a
false positive because the uint16_checksum doesn't depend on the order
of the input uint16_t items.

https://bugzilla.samba.org/show_bug.cgi?id=13588

Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 48335725deecdbdb24a9176cf31e9611c9deda49)
ctdb/common/system_socket.c