diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2017-02-03 09:13:26 +0100 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-02-03 11:55:03 +0000 |
commit | 1a1e7e4b8df3915c2569f9933ef226784632e498 (patch) | |
tree | cd8eab59e38bd7613cd97855b05dcdcd767b97c4 /epan/dissectors/packet-btle.c | |
parent | 3481ca8733601f88c3c4c535d19b43ea99a35bbb (diff) |
BTLE: check connection_info presence before trying to perform reassembly
Bug: 13379
Change-Id: Idafa780f24bf9f181c0913cbe16a0cfa9bce382e
Reviewed-on: https://code.wireshark.org/review/19927
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@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-btle.c')
-rw-r--r-- | epan/dissectors/packet-btle.c | 100 |
1 files changed, 52 insertions, 48 deletions
diff --git a/epan/dissectors/packet-btle.c b/epan/dissectors/packet-btle.c index 103fe45ec9..53e9f8e4a9 100644 --- a/epan/dissectors/packet-btle.c +++ b/epan/dissectors/packet-btle.c @@ -872,36 +872,38 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) case 0x01: /* Continuation fragment of an L2CAP message, or an Empty PDU */ /* TODO: Try reassemble cases 0x01 and 0x02 */ if (length > 0) { - tvbuff_t *new_tvb; + tvbuff_t *new_tvb = NULL; - if ((!pinfo->fd->flags.visited) && (connection_info)) { - if (connection_info->segmentation_started == 1) { - connection_info->segment_len_rem = connection_info->segment_len_rem - length; - if(connection_info->segment_len_rem > 0){ - btle_frame_info->more_fragments = 1; - } - else { - btle_frame_info->more_fragments = 0; - connection_info->segmentation_started = 0; - connection_info->segment_len_rem = 0; + pinfo->fragmented = TRUE; + if (connection_info) { + if (!pinfo->fd->flags.visited) { + if (connection_info->segmentation_started == 1) { + connection_info->segment_len_rem = connection_info->segment_len_rem - length; + if(connection_info->segment_len_rem > 0){ + btle_frame_info->more_fragments = 1; + } + else { + btle_frame_info->more_fragments = 0; + connection_info->segmentation_started = 0; + connection_info->segment_len_rem = 0; + } } } + frag_btl2cap_msg = fragment_add_seq_next(&btle_l2cap_msg_reassembly_table, + tvb, offset, + pinfo, + connection_info->access_address, /* guint32 ID for fragments belonging together */ + NULL, /* data* */ + length, /* Fragment length */ + btle_frame_info->more_fragments); /* More fragments */ + + new_tvb = process_reassembled_data(tvb, offset, pinfo, + "Reassembled L2CAP", + frag_btl2cap_msg, + &btle_l2cap_msg_frag_items, + NULL, + btle_tree); } - pinfo->fragmented = TRUE; - frag_btl2cap_msg = fragment_add_seq_next(&btle_l2cap_msg_reassembly_table, - tvb, offset, - pinfo, - connection_info->access_address, /* guint32 ID for fragments belonging together */ - NULL, /* data* */ - length, /* Fragment length */ - btle_frame_info->more_fragments); /* More fragments */ - - new_tvb = process_reassembled_data(tvb, offset, pinfo, - "Reassembled L2CAP", - frag_btl2cap_msg, - &btle_l2cap_msg_frag_items, - NULL, - btle_tree); if (new_tvb) { bthci_acl_data_t *acl_data; @@ -939,30 +941,32 @@ dissect_btle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) gint le_frame_len = tvb_get_letohs(tvb, offset); if (le_frame_len > length) { /* TODO: Try reassemble cases 0x01 and 0x02 */ - if ((!pinfo->fd->flags.visited) && (connection_info )){ - connection_info->segmentation_started = 1; - /* The first two octets in the L2CAP PDU contain the length of the entire - * L2CAP PDU in octets, excluding the Length and CID fields(4 octets). - */ - connection_info->segment_len_rem = le_frame_len + 4 - length; - btle_frame_info->more_fragments = 1; - } pinfo->fragmented = TRUE; + if (connection_info) { + if (!pinfo->fd->flags.visited) { + connection_info->segmentation_started = 1; + /* The first two octets in the L2CAP PDU contain the length of the entire + * L2CAP PDU in octets, excluding the Length and CID fields(4 octets). + */ + connection_info->segment_len_rem = le_frame_len + 4 - length; + btle_frame_info->more_fragments = 1; + } - frag_btl2cap_msg = fragment_add_seq_next(&btle_l2cap_msg_reassembly_table, - tvb, offset, - pinfo, - connection_info->access_address, /* guint32 ID for fragments belonging together */ - NULL, - length, /* Fragment length */ - TRUE); /* More fragments */ - - process_reassembled_data(tvb, offset, pinfo, - "Reassembled L2CAP", - frag_btl2cap_msg, - &btle_l2cap_msg_frag_items, - NULL, - btle_tree); + frag_btl2cap_msg = fragment_add_seq_next(&btle_l2cap_msg_reassembly_table, + tvb, offset, + pinfo, + connection_info->access_address, /* guint32 ID for fragments belonging together */ + NULL, + length, /* Fragment length */ + TRUE); /* More fragments */ + + process_reassembled_data(tvb, offset, pinfo, + "Reassembled L2CAP", + frag_btl2cap_msg, + &btle_l2cap_msg_frag_items, + NULL, + btle_tree); + } col_set_str(pinfo->cinfo, COL_INFO, "L2CAP Fragment Start"); proto_tree_add_item(btle_tree, hf_l2cap_fragment, tvb, offset, length, ENC_NA); |