From 42c9bee36fc16485ade4b4e59cf7fc709e26a970 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 25 Sep 2018 11:57:09 -0700 Subject: [PATCH] Flag invalid markers. Change-Id: I8d99fa2b46ffb96100ea0e47273761d9c47e14cb Reviewed-on: https://code.wireshark.org/review/29831 Reviewed-by: Guy Harris --- epan/dissectors/packet-bgp.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/epan/dissectors/packet-bgp.c b/epan/dissectors/packet-bgp.c index 3d831c48d8..b6c979c470 100644 --- a/epan/dissectors/packet-bgp.c +++ b/epan/dissectors/packet-bgp.c @@ -2079,6 +2079,7 @@ static gint ett_bgp_prefix_sid_originator_srgb_blocks = -1; static gint ett_bgp_prefix_sid_label_index = -1; static gint ett_bgp_prefix_sid_ipv6 = -1; +static expert_field ei_bgp_marker_invalid = EI_INIT; static expert_field ei_bgp_cap_len_bad = EI_INIT; static expert_field ei_bgp_cap_gr_helper_mode_only = EI_INIT; static expert_field ei_bgp_notify_minor_unknown = EI_INIT; @@ -8015,8 +8016,13 @@ dissect_bgp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 bgp_len; /* Message length */ guint8 bgp_type; /* Message type */ const char *typ; /* Message type (string) */ + proto_item *ti_marker = NULL;/* marker item */ proto_item *ti_len = NULL; /* length item */ proto_tree *bgp_tree = NULL; /* BGP packet tree */ + static const guint8 valid_marker[BGP_MARKER_SIZE] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF + }; bgp_len = tvb_get_ntohs(tvb, BGP_MARKER_SIZE); bgp_type = tvb_get_guint8(tvb, BGP_MARKER_SIZE + 2); @@ -8058,7 +8064,11 @@ dissect_bgp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, break; } - proto_tree_add_item(bgp_tree, hf_bgp_marker, tvb, 0, 16, ENC_NA); + ti_marker = proto_tree_add_item(bgp_tree, hf_bgp_marker, tvb, 0, + BGP_MARKER_SIZE, ENC_NA); + if (tvb_memeql(tvb, 0, valid_marker, BGP_MARKER_SIZE) != 0) { + expert_add_info(pinfo, ti_marker, &ei_bgp_marker_invalid); + } ti_len = proto_tree_add_item(bgp_tree, hf_bgp_length, tvb, 16, 2, ENC_BIG_ENDIAN); } @@ -10015,6 +10025,7 @@ proto_register_bgp(void) &ett_bgp_prefix_sid_originator_srgb_blocks, }; static ei_register_info ei[] = { + { &ei_bgp_marker_invalid, { "bgp.marker_invalid", PI_MALFORMED, PI_ERROR, "Marker is not all ones", EXPFILL }}, { &ei_bgp_cap_len_bad, { "bgp.cap.length.bad", PI_MALFORMED, PI_ERROR, "Capability length is wrong", EXPFILL }}, { &ei_bgp_cap_gr_helper_mode_only, { "bgp.cap.gr.helper_mode_only", PI_REQUEST_CODE, PI_CHAT, "Graceful Restart Capability supported in Helper mode only", EXPFILL }}, { &ei_bgp_notify_minor_unknown, { "bgp.notify.minor_error.unknown", PI_UNDECODED, PI_NOTE, "Unknown notification error", EXPFILL }},