diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-06-14 08:09:59 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-06-14 08:09:59 +0000 |
commit | 026db5a26f47ad881357442ec88a2e8c6e3d290d (patch) | |
tree | eefc5d9624753e553c00b58338dba6ddd4af26fd /packet-tcp.c | |
parent | 248e1f3430ed613bc4b87a180a68063ca0475a50 (diff) | |
download | wireshark-026db5a26f47ad881357442ec88a2e8c6e3d290d.tar.gz wireshark-026db5a26f47ad881357442ec88a2e8c6e3d290d.tar.bz2 wireshark-026db5a26f47ad881357442ec88a2e8c6e3d290d.zip |
Check for a bogus TCP header length, and don't try to do dissection if
it's bogus.
svn path=/trunk/; revision=3542
Diffstat (limited to 'packet-tcp.c')
-rw-r--r-- | packet-tcp.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/packet-tcp.c b/packet-tcp.c index 4b8a95347c..a2107325e6 100644 --- a/packet-tcp.c +++ b/packet-tcp.c @@ -1,7 +1,7 @@ /* packet-tcp.c * Routines for TCP packet disassembly * - * $Id: packet-tcp.c,v 1.103 2001/06/08 08:41:03 guy Exp $ + * $Id: packet-tcp.c,v 1.104 2001/06/14 08:09:59 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -116,6 +116,9 @@ typedef struct _e_tcphdr { guint16 th_urp; } e_tcphdr; +/* Minimum TCP header length. */ +#define TCPH_MIN_LEN 20 + /* * TCP option */ @@ -476,6 +479,20 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* Compute the sequence number of next octet after this segment. */ nxtseq = th.th_seq + seglen; + if (hlen < TCPH_MIN_LEN) { + if (check_col(pinfo->fd, COL_INFO)) + col_add_fstr(pinfo->fd, COL_INFO, "Bogus TCP header length (%u, must be at least %u)", + hlen, TCPH_MIN_LEN); + ti = proto_tree_add_item(tree, proto_tcp, tvb, offset, hlen, FALSE); + tcp_tree = proto_item_add_subtree(ti, ett_tcp); + if (tree) { + proto_tree_add_uint_format(tcp_tree, hf_tcp_hdr_len, tvb, offset, 1, hlen, + "Header length: %u bytes (bogus, must be at least %u)", hlen, + TCPH_MIN_LEN); + } + return; + } + if (check_col(pinfo->fd, COL_INFO)) { if (th.th_flags & TH_URG) col_append_fstr(pinfo->fd, COL_INFO, "%s > %s [%s] Seq=%u Ack=%u Win=%u Urg=%u Len=%d", @@ -488,8 +505,12 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) } if (tree) { - if (tcp_summary_in_tree) { - ti = proto_tree_add_protocol_format(tree, proto_tcp, tvb, offset, hlen, "Transmission Control Protocol, Src Port: %s (%u), Dst Port: %s (%u), Seq: %u, Ack: %u", get_tcp_port(th.th_sport), th.th_sport, get_tcp_port(th.th_dport), th.th_dport, th.th_seq, th.th_ack); + if (tcp_summary_in_tree && hlen >= TCPH_MIN_LEN) { + ti = proto_tree_add_protocol_format(tree, proto_tcp, tvb, offset, + hlen, + "Transmission Control Protocol, Src Port: %s (%u), Dst Port: %s (%u), Seq: %u, Ack: %u", + get_tcp_port(th.th_sport), th.th_sport, + get_tcp_port(th.th_dport), th.th_dport, th.th_seq, th.th_ack); } else { ti = proto_tree_add_item(tree, proto_tcp, tvb, offset, hlen, FALSE); |