diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2015-08-23 18:44:31 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-08-24 10:48:35 +0000 |
commit | a5b5c5a850a50b827949e7bb25b05c80ae1fcb96 (patch) | |
tree | 2e308a2bf07c4a84a0495ac098ea3a56f858eb81 /epan/dissectors/packet-fc.c | |
parent | 517f4d4ffdea0047021a2a9593a3e9a6c36dae93 (diff) |
fc: don't THROW() an exception from a dissector
bring up an expert info and exit
Change-Id: Icbbafb8b7187a66d3ddc9a674502ad728b7c4ffc
Reviewed-on: https://code.wireshark.org/review/10222
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-fc.c')
-rw-r--r-- | epan/dissectors/packet-fc.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/epan/dissectors/packet-fc.c b/epan/dissectors/packet-fc.c index 5b06e7793e..1a32bd998f 100644 --- a/epan/dissectors/packet-fc.c +++ b/epan/dissectors/packet-fc.c @@ -139,6 +139,8 @@ static gint ett_fcbls = -1; static gint ett_fc_vft = -1; static expert_field ei_fccrc = EI_INIT; +static expert_field ei_short_hdr = EI_INIT; +static expert_field ei_frag_size = EI_INIT; static dissector_handle_t fc_handle, fcsof_handle; static dissector_table_t fcftype_dissector_table; @@ -1021,8 +1023,11 @@ dissect_fc_helper (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_exchg_resp = (f_ctl & FC_FCTL_EXCHANGE_RESPONDER) != 0; } - if (tvb_reported_length (tvb) < FC_HEADER_SIZE) - THROW(ReportedBoundsError); + if (tvb_reported_length (tvb) < FC_HEADER_SIZE) { + proto_tree_add_expert(fc_tree, pinfo, &ei_short_hdr, + tvb, 0, tvb_reported_length(tvb)); + return; + } frag_size = tvb_reported_length (tvb)-FC_HEADER_SIZE; @@ -1034,14 +1039,20 @@ dissect_fc_helper (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean if ((fc_data->ethertype == ETHERTYPE_UNK) || (fc_data->ethertype == ETHERTYPE_FCFT)) { if ((frag_size < MDSHDR_TRAILER_SIZE) || ((frag_size == MDSHDR_TRAILER_SIZE) && (ftype != FC_FTYPE_LINKCTL) && - (ftype != FC_FTYPE_BLS) && (ftype != FC_FTYPE_OHMS))) - THROW(ReportedBoundsError); + (ftype != FC_FTYPE_BLS) && (ftype != FC_FTYPE_OHMS))) { + proto_tree_add_expert(fc_tree, pinfo, &ei_short_hdr, + tvb, FC_HEADER_SIZE, frag_size); + return; + } frag_size -= MDSHDR_TRAILER_SIZE; } else if (fc_data->ethertype == ETHERTYPE_BRDWALK) { if ((frag_size <= 8) || ((frag_size == MDSHDR_TRAILER_SIZE) && (ftype != FC_FTYPE_LINKCTL) && - (ftype != FC_FTYPE_BLS) && (ftype != FC_FTYPE_OHMS))) - THROW(ReportedBoundsError); + (ftype != FC_FTYPE_BLS) && (ftype != FC_FTYPE_OHMS))) { + proto_tree_add_expert(fc_tree, pinfo, &ei_short_hdr, + tvb, FC_HEADER_SIZE, frag_size); + return; + } frag_size -= 8; /* 4 byte of FC CRC + 4 bytes of error+EOF = 8 bytes */ } @@ -1518,7 +1529,14 @@ proto_register_fc(void) }; static ei_register_info ei[] = { - { &ei_fccrc, { "fc.crc.bad", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }}, + { &ei_fccrc, + { "fc.crc.bad", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }}, + { &ei_short_hdr, + { "fc.short_hdr", PI_MALFORMED, PI_ERROR, + "Packet length is shorter than the required header", EXPFILL }}, + { &ei_frag_size, + { "fc.frag_size", PI_MALFORMED, PI_ERROR, + "Invalid fragment size", EXPFILL }} }; module_t *fc_module; |