X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/5922b80797378d98e7033523c3d62de353a87357..ad69daa2e4cf9ce6789295bd7f55a55ac4d9d0b2:/print-tcp.c diff --git a/print-tcp.c b/print-tcp.c index 6deb97b3..ab3dbbf3 100644 --- a/print-tcp.c +++ b/print-tcp.c @@ -262,21 +262,21 @@ tcp_print(netdissect_options *ndo, struct tha6 tha; tcp_seq_hash = tcp_seq_hash6; - src = (const void *)&ip6->ip6_src; - dst = (const void *)&ip6->ip6_dst; + src = (const void *)ip6->ip6_src; + dst = (const void *)ip6->ip6_dst; if (sport > dport) rev = 1; else if (sport == dport) { - if (UNALIGNED_MEMCMP(src, dst, sizeof ip6->ip6_dst) > 0) + if (UNALIGNED_MEMCMP(src, dst, sizeof(ip6->ip6_dst)) > 0) rev = 1; } if (rev) { - UNALIGNED_MEMCPY(&tha.src, dst, sizeof ip6->ip6_dst); - UNALIGNED_MEMCPY(&tha.dst, src, sizeof ip6->ip6_src); + UNALIGNED_MEMCPY(&tha.src, dst, sizeof(ip6->ip6_dst)); + UNALIGNED_MEMCPY(&tha.dst, src, sizeof(ip6->ip6_src)); tha.port = dport << 16 | sport; } else { - UNALIGNED_MEMCPY(&tha.dst, dst, sizeof ip6->ip6_dst); - UNALIGNED_MEMCPY(&tha.src, src, sizeof ip6->ip6_src); + UNALIGNED_MEMCPY(&tha.dst, dst, sizeof(ip6->ip6_dst)); + UNALIGNED_MEMCPY(&tha.src, src, sizeof(ip6->ip6_src)); tha.port = sport << 16 | dport; } @@ -288,12 +288,15 @@ tcp_print(netdissect_options *ndo, if (!th->nxt || (flags & TH_SYN)) { /* didn't find it or new conversation */ + /* calloc() return used by the 'tcp_seq_hash6' + hash table: do not free() */ if (th->nxt == NULL) { th->nxt = (struct tcp_seq_hash6 *) calloc(1, sizeof(*th)); if (th->nxt == NULL) (*ndo->ndo_error)(ndo, - "tcp_print: calloc"); + S_ERR_ND_MEM_ALLOC, + "tcp_print: calloc"); } th->addr = tha; if (rev) @@ -318,20 +321,20 @@ tcp_print(netdissect_options *ndo, if (sport > dport) rev = 1; else if (sport == dport) { - if (UNALIGNED_MEMCMP(ip->ip_src, ip->ip_dst, sizeof ip->ip_dst) > 0) + if (UNALIGNED_MEMCMP(ip->ip_src, ip->ip_dst, sizeof(ip->ip_dst)) > 0) rev = 1; } if (rev) { UNALIGNED_MEMCPY(&tha.src, ip->ip_dst, - sizeof ip->ip_dst); + sizeof(ip->ip_dst)); UNALIGNED_MEMCPY(&tha.dst, ip->ip_src, - sizeof ip->ip_src); + sizeof(ip->ip_src)); tha.port = dport << 16 | sport; } else { UNALIGNED_MEMCPY(&tha.dst, ip->ip_dst, - sizeof ip->ip_dst); + sizeof(ip->ip_dst)); UNALIGNED_MEMCPY(&tha.src, ip->ip_src, - sizeof ip->ip_src); + sizeof(ip->ip_src)); tha.port = sport << 16 | dport; } @@ -343,12 +346,15 @@ tcp_print(netdissect_options *ndo, if (!th->nxt || (flags & TH_SYN)) { /* didn't find it or new conversation */ + /* calloc() return used by the 'tcp_seq_hash4' + hash table: do not free() */ if (th->nxt == NULL) { th->nxt = (struct tcp_seq_hash *) calloc(1, sizeof(*th)); if (th->nxt == NULL) (*ndo->ndo_error)(ndo, - "tcp_print: calloc"); + S_ERR_ND_MEM_ALLOC, + "tcp_print: calloc"); } th->addr = tha; if (rev)