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>
This commit is contained in:
Pascal Quantin 2017-02-03 09:13:26 +01:00 committed by Anders Broman
parent 3481ca8733
commit 1a1e7e4b8d
1 changed files with 51 additions and 47 deletions

View File

@ -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;
}
}
}
}
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 */
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);
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 */
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);
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);