diff options
author | Nardi Ivan <nardi.ivan@gmail.com> | 2018-12-20 17:55:17 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-12-21 06:31:12 +0000 |
commit | 5feb326312b2171f46bdd76ce677883b17b3da0a (patch) | |
tree | 6b737e31bb8cba30fcb4454e9d7b19856faa3317 /epan | |
parent | cea16864953e026ad9a0047534f8d6e8fb2648fc (diff) |
ip, tcp: add expert info for invalid header length
Change-Id: I58c1b20304aabcff144667cfbbcc774010fc2a16
Reviewed-on: https://code.wireshark.org/review/31148
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-ip.c | 9 | ||||
-rw-r--r-- | epan/dissectors/packet-tcp.c | 9 |
2 files changed, 12 insertions, 6 deletions
diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c index 8a33f6df4c..3362284fdf 100644 --- a/epan/dissectors/packet-ip.c +++ b/epan/dissectors/packet-ip.c @@ -261,6 +261,7 @@ static expert_field ei_ip_ttl_lncb = EI_INIT; static expert_field ei_ip_ttl_too_small = EI_INIT; static expert_field ei_ip_cipso_tag = EI_INIT; static expert_field ei_ip_bogus_ip_version = EI_INIT; +static expert_field ei_ip_bogus_header_length = EI_INIT; static dissector_handle_t ip_handle; static dissector_table_t ip_option_table; @@ -1918,9 +1919,10 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* col_add_fstr(pinfo->cinfo, COL_INFO, "Bogus IP header length (%u, must be at least %u)", hlen, IPH_MIN_LEN); - - proto_tree_add_uint_bits_format_value(ip_tree, hf_ip_hdr_len, tvb, (offset<<3)+4, 4, hlen, - "%u bytes (bogus, must be at least %u)", hlen, IPH_MIN_LEN); + tf = proto_tree_add_uint_bits_format_value(ip_tree, hf_ip_hdr_len, tvb, (offset<<3)+4, 4, hlen, + "%u bytes (%u)", hlen, hlen>>2); + expert_add_info_format(pinfo, tf, &ei_ip_bogus_header_length, + "Bogus IP header length (%u, must be at least %u)", hlen, IPH_MIN_LEN); return tvb_captured_length(tvb); } @@ -2911,6 +2913,7 @@ proto_register_ip(void) { &ei_ip_ttl_too_small, { "ip.ttl.too_small", PI_SEQUENCE, PI_NOTE, "Time To Live", EXPFILL }}, { &ei_ip_cipso_tag, { "ip.cipso.malformed", PI_SEQUENCE, PI_ERROR, "Malformed CIPSO tag", EXPFILL }}, { &ei_ip_bogus_ip_version, { "ip.bogus_ip_version", PI_PROTOCOL, PI_ERROR, "Bogus IP version", EXPFILL }}, + { &ei_ip_bogus_header_length, { "ip.bogus_header_length", PI_PROTOCOL, PI_ERROR, "Bogus IP header length", EXPFILL }}, }; /* Decode As handling */ diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index e25f18a487..a232ab1f19 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -393,6 +393,7 @@ static expert_field ei_tcp_checksum_bad = EI_INIT; static expert_field ei_tcp_urgent_pointer_non_zero = EI_INIT; static expert_field ei_tcp_suboption_malformed = EI_INIT; static expert_field ei_tcp_nop = EI_INIT; +static expert_field ei_tcp_bogus_header_length = EI_INIT; /* static expert_field ei_mptcp_analysis_unexpected_idsn = EI_INIT; */ static expert_field ei_mptcp_analysis_echoed_key_mismatch = EI_INIT; @@ -6197,9 +6198,10 @@ dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) col_append_fstr(pinfo->cinfo, COL_INFO, ", bogus TCP header length (%u, must be at least %u)", tcph->th_hlen, TCPH_MIN_LEN); if (tree) { - proto_tree_add_uint_format_value(tcp_tree, hf_tcp_hdr_len, tvb, offset + 12, 1, tcph->th_hlen, - "%u bytes (bogus, must be at least %u)", tcph->th_hlen, - TCPH_MIN_LEN); + tf = proto_tree_add_uint_bits_format_value(tcp_tree, hf_tcp_hdr_len, tvb, (offset + 12) << 3, 4, tcph->th_hlen, + "%u bytes (%u)", tcph->th_hlen, tcph->th_hlen >> 2); + expert_add_info_format(pinfo, tf, &ei_tcp_bogus_header_length, + "Bogus TCP header length (%u, must be at least %u)", tcph->th_hlen, TCPH_MIN_LEN); } return offset+12; } @@ -7529,6 +7531,7 @@ proto_register_tcp(void) { &ei_tcp_urgent_pointer_non_zero, { "tcp.urgent_pointer.non_zero", PI_PROTOCOL, PI_NOTE, "The urgent pointer field is nonzero while the URG flag is not set", EXPFILL }}, { &ei_tcp_suboption_malformed, { "tcp.suboption_malformed", PI_MALFORMED, PI_ERROR, "suboption would go past end of option", EXPFILL }}, { &ei_tcp_nop, { "tcp.nop", PI_PROTOCOL, PI_WARN, "4 NOP in a row - a router may have removed some options", EXPFILL }}, + { &ei_tcp_bogus_header_length, { "tcp.bogus_header_length", PI_PROTOCOL, PI_ERROR, "Bogus TCP Header length", EXPFILL }}, }; static ei_register_info mptcp_ei[] = { |