diff options
author | Alexis La Goutte <alexis.lagoutte@gmail.com> | 2014-10-12 20:56:17 +0200 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-10-13 15:47:05 +0000 |
commit | 24b6a1141a883ac369e9b7da118c462741cc3246 (patch) | |
tree | eb498d5d4e06a5efcde3275f835aa89313873a34 /epan/dissectors/packet-ipv6.c | |
parent | a9497befebd3fe5c44c401e186ddb4ddb9e00bea (diff) |
IPv6 RPL option is read as less bytes than it is
Add check if the opt len equal to the "calculcate" length
and display expert info if not.. also replace offset by the opt len
Bug:10559
Bug:10561
Change-Id: I6e80e4055b6d0c5ef3f030c544cd1629e6b9abec
Reviewed-on: https://code.wireshark.org/review/4627
Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-ipv6.c')
-rw-r--r-- | epan/dissectors/packet-ipv6.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/epan/dissectors/packet-ipv6.c b/epan/dissectors/packet-ipv6.c index 84af5b3505..addc28ca90 100644 --- a/epan/dissectors/packet-ipv6.c +++ b/epan/dissectors/packet-ipv6.c @@ -192,6 +192,7 @@ static int hf_ipv6_opt_rpl_flag_rsv = -1; static int hf_ipv6_opt_rpl_instance_id = -1; static int hf_ipv6_opt_rpl_senderrank = -1; static int hf_ipv6_opt_experimental = -1; +static int hf_ipv6_opt_unknown_data = -1; static int hf_ipv6_opt_unknown = -1; static int hf_ipv6_dst_opt = -1; static int hf_ipv6_hop_opt = -1; @@ -331,6 +332,7 @@ static expert_field ei_ipv6_routing_hdr_rpl_reserved = EI_INIT; static expert_field ei_ipv6_opt_tel_invalid_len = EI_INIT; static expert_field ei_ipv6_opt_jumbo_invalid_len = EI_INIT; static expert_field ei_ipv6_opt_rtalert_invalid_len = EI_INIT; +static expert_field ei_ipv6_opt_unknown_data = EI_INIT; static expert_field ei_ipv6_mipv6_home_address_invalid_len = EI_INIT; static expert_field ei_ipv6_shim6_opt_elemlen_invalid = EI_INIT; static expert_field ei_ipv6_shim6_checksum_bad = EI_INIT; @@ -1042,7 +1044,7 @@ static int dissect_opts(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info * pinfo, const int hf_option_item, ws_ip* iph) { int len; - int offset_end; + int offset_end, offset_opt_end; proto_tree *dstopt_tree, *opt_tree; proto_item *ti, *ti_len, *ti_opt, *ti_opt_len; guint8 opt_len, opt_type; @@ -1091,6 +1093,7 @@ dissect_opts(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info * pinfo, c opt_len = tvb_get_guint8(tvb, offset); proto_item_set_len(ti_opt, opt_len + 2); offset += 1; + offset_opt_end = offset + opt_len; switch (opt_type) { case IP6OPT_PADN: @@ -1247,6 +1250,11 @@ dissect_opts(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info * pinfo, c offset += opt_len; break; } + if(offset < offset_opt_end){ + ti = proto_tree_add_item(opt_tree, hf_ipv6_opt_unknown_data, tvb, offset, offset_opt_end - offset, ENC_NA); + expert_add_info(pinfo, ti, &ei_ipv6_opt_unknown_data); + offset = offset_opt_end; + } /* Close the ) to option root label */ proto_item_append_text(ti_opt, ")"); } @@ -2538,6 +2546,9 @@ proto_register_ipv6(void) { "Experimental Option","ipv6.opt.experimental", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + { &hf_ipv6_opt_unknown_data, + { "Unknown Data", "ipv6.opt_unknown_data", FT_BYTES, BASE_NONE, NULL, 0x0, + "Not interpreted Data", HFILL }}, { &hf_ipv6_opt_unknown, { "Unknown Option Payload","ipv6.opt.unknown", FT_BYTES, BASE_NONE, NULL, 0x0, @@ -2938,6 +2949,7 @@ proto_register_ipv6(void) { &ei_ipv6_opt_tel_invalid_len, { "ipv6.opt.tel.invalid_len", PI_MALFORMED, PI_ERROR, "Tunnel Encapsulation Limit: Invalid length", EXPFILL }}, { &ei_ipv6_opt_jumbo_invalid_len, { "ipv6.opt.jumbo.invalid_len", PI_MALFORMED, PI_ERROR, "Jumbo payload: Invalid length", EXPFILL }}, { &ei_ipv6_opt_rtalert_invalid_len, { "ipv6.opt.router_alert.invalid_len", PI_MALFORMED, PI_ERROR, "Router alert: Invalid Length", EXPFILL }}, + { &ei_ipv6_opt_unknown_data, { "ipv6.opt.unknown_data.expert", PI_UNDECODED, PI_NOTE, "Unknown Data (not interpreted)", EXPFILL }}, { &ei_ipv6_mipv6_home_address_invalid_len, { "ipv6.mipv6_home_address.invalid_len", PI_MALFORMED, PI_ERROR, "Home Address: Invalid length", EXPFILL }}, { &ei_ipv6_shim6_opt_elemlen_invalid, { "ipv6.shim6.opt.elemlen.invalid", PI_MALFORMED, PI_ERROR, "Invalid element length", EXPFILL }}, { &ei_ipv6_shim6_checksum_bad, { "ipv6.shim6.checksum_bad.expert", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }}, |