]> The Tcpdump Group git mirrors - tcpdump/commitdiff
More possibly-unaligned memcpy()s and assignments - use unaligned_memcpy().
authorGuy Harris <[email protected]>
Sat, 18 Jan 2014 01:24:23 +0000 (17:24 -0800)
committerGuy Harris <[email protected]>
Sat, 18 Jan 2014 01:24:23 +0000 (17:24 -0800)
print-ip.c
print-ip6.c

index 128834c40a5a97ab3434e233ba73ab3d9c98848f..2a3f1e67fa8329de905699aa25ba72c962a2df0f 100644 (file)
@@ -117,12 +117,12 @@ ip_finddst(const struct ip *ip)
                case IPOPT_LSRR:
                        if (len < 7)
                                break;
-                       memcpy(&retval, cp + len - 4, 4);
+                       unaligned_memcpy(&retval, cp + len - 4, 4);
                        return retval;
                }
        }
 trunc:
-       memcpy(&retval, &ip->ip_dst.s_addr, sizeof(u_int32_t));
+       unaligned_memcpy(&retval, &ip->ip_dst.s_addr, sizeof(u_int32_t));
        return retval;
 }
 
@@ -146,9 +146,9 @@ nextproto4_cksum(const struct ip *ip, const u_int8_t *data,
        ph.len = htons((u_int16_t)len);
        ph.mbz = 0;
        ph.proto = next_proto;
-       memcpy(&ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
+       unaligned_memcpy(&ph.src, &ip->ip_src.s_addr, sizeof(u_int32_t));
        if (IP_HL(ip) == 5)
-               memcpy(&ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
+               unaligned_memcpy(&ph.dst, &ip->ip_dst.s_addr, sizeof(u_int32_t));
        else
                ph.dst = ip_finddst(ip);
 
index 3113cc6cd7bc3e1ef39d03e720966958784c9461..35c9210170e91d2c8968c4d9c2830ff0b3924567 100644 (file)
@@ -57,8 +57,8 @@ nextproto6_cksum(const struct ip6_hdr *ip6, const u_int8_t *data,
 
         /* pseudo-header */
         memset(&ph, 0, sizeof(ph));
-        ph.ph_src = ip6->ip6_src;
-        ph.ph_dst = ip6->ip6_dst;
+        unaligned_memcpy(&ph.ph_src, &ip6->ip6_src, sizeof (struct in6_addr));
+        unaligned_memcpy(&ph.ph_dst, &ip6->ip6_dst, sizeof (struct in6_addr));
         ph.ph_len = htonl(len);
         ph.ph_nxt = next_proto;