]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Don't dereference the header assuming alignment.
authorGuy Harris <[email protected]>
Tue, 26 Dec 2017 09:17:12 +0000 (01:17 -0800)
committerGuy Harris <[email protected]>
Tue, 26 Dec 2017 09:17:12 +0000 (01:17 -0800)
It's probably safe to do so, but don't rely on it.

Also, use parens around the argument to sizeof, to match the style used
elsewhere.

print-enc.c

index d8f0a9e62426db26c4b4a02fc6c1a7c3617ac85f..502e32331b22403f4b2994de67d0a763eda39f0e 100644 (file)
@@ -127,11 +127,11 @@ enc_if_print(netdissect_options *ndo,
         * The SPI field is always in network byte order, i.e. big-
         * endian.
         */
-       UNALIGNED_MEMCPY(&af, &hdr->af, sizeof af);
-       UNALIGNED_MEMCPY(&flags, &hdr->flags, sizeof flags);
+       UNALIGNED_MEMCPY(&af, &hdr->af, sizeof (af));
+       UNALIGNED_MEMCPY(&flags, &hdr->flags, sizeof (flags));
        if ((af & 0xFFFF0000) != 0) {
                af = SWAPLONG(af);
-               flags = SWAPLONG(hdr->flags);
+               flags = SWAPLONG(flags);
        }
 
        if (flags == 0)