]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Point to IP addresses with "void *"s.
authorGuy Harris <[email protected]>
Wed, 15 Jan 2014 22:40:52 +0000 (14:40 -0800)
committerGuy Harris <[email protected]>
Wed, 15 Jan 2014 22:40:52 +0000 (14:40 -0800)
This keeps GCC from assuming the IP addresses are aligned and generating
32-bit load/store pairs on SPARC; those require alignment and cause
tcpdump to crash.

print-tcp.c

index dbb40416b365ee6a60999c5c853e406278c1898e..b63bc4ebf21fd53303ff74e0f5b32e2fd766bad4 100644 (file)
@@ -305,12 +305,18 @@ tcp_print(register const u_char *bp, register u_int length,
 #endif /*INET6*/
                         register struct tcp_seq_hash *th;
                         struct tcp_seq_hash *tcp_seq_hash;
-                        const struct in_addr *src, *dst;
+                        const void *src, *dst;
                         struct tha tha;
 
                         tcp_seq_hash = tcp_seq_hash4;
-                        src = &ip->ip_src;
-                        dst = &ip->ip_dst;
+                       /*
+                        * We use "void *" to keep the compiler from
+                        * assuming the structures are aligned and
+                        * generating non-unaligned-safe code for
+                        * the copies.
+                        */
+                        src = (const void *)&ip->ip_src;
+                        dst = (const void *)&ip->ip_dst;
                         if (sport > dport)
                                 rev = 1;
                         else if (sport == dport) {