X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/6b8ed9649e08215cd2acf7702e178ce41b18d932..5f1caad63354a9066285cdc7be37eaa003c86cf4:/print-tcp.c diff --git a/print-tcp.c b/print-tcp.c index 3a89e8d3..f00ff325 100644 --- a/print-tcp.c +++ b/print-tcp.c @@ -189,8 +189,6 @@ tcp_print(netdissect_options *ndo, sport = EXTRACT_16BITS(&tp->th_sport); dport = EXTRACT_16BITS(&tp->th_dport); - hlen = TH_OFF(tp) * 4; - if (ip6) { if (ip6->ip6_nxt == IPPROTO_TCP) { ND_PRINT((ndo, "%s.%s > %s.%s: ", @@ -215,14 +213,16 @@ tcp_print(netdissect_options *ndo, } } + ND_TCHECK(*tp); + + hlen = TH_OFF(tp) * 4; + if (hlen < sizeof(*tp)) { ND_PRINT((ndo, " tcp %d [bad hdr length %u - too short, < %lu]", length - hlen, hlen, (unsigned long)sizeof(*tp))); return; } - ND_TCHECK(*tp); - seq = EXTRACT_32BITS(&tp->th_seq); ack = EXTRACT_32BITS(&tp->th_ack); win = EXTRACT_16BITS(&tp->th_win);