pcapng: fix more interface ID checks.

Fix the check for the Interface Statistics Block as well.

Make the check for the Simple Packet BLock similar to the other checks -
at the beginning, set interface_id to 0 and then check interface_id
against the size of the array.

Change-Id: Ib05255fe13eca6292447f365b62ff3094805bd4a
Reviewed-on: https://code.wireshark.org/review/37071
Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <gharris@sonic.net>
This commit is contained in:
Guy Harris 2020-05-03 11:16:58 -07:00 committed by Guy Harris
parent 29340f1b33
commit 60622e63fd
1 changed files with 5 additions and 7 deletions

View File

@ -1410,7 +1410,8 @@ static gint dissect_block(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb,
break;
case BLOCK_SIMPLE_PACKET:
if (0 == wmem_array_get_count(info->interfaces)) {
interface_id = 0;
if (interface_id >= wmem_array_get_count(info->interfaces)) {
expert_add_info(pinfo, block_tree, &ei_missing_idb);
}
@ -1419,8 +1420,6 @@ static gint dissect_block(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb,
proto_tree_add_item_ret_uint(block_data_tree, hf_pcapng_packet_length, tvb, offset, 4, encoding, &captured_length);
offset += 4;
interface_id = 0;
packet_data_item = proto_tree_add_item(block_data_tree, hf_pcapng_packet_data, tvb, offset, captured_length, encoding);
if (pref_dissect_next_layer && interface_id < wmem_array_get_count(info->interfaces)) {
@ -1570,12 +1569,11 @@ static gint dissect_block(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb,
break;
case BLOCK_INTERFACE_STATISTICS:
if (0 == wmem_array_get_count(info->interfaces) && info->frame_number == 1) {
expert_add_info(pinfo, block_tree, &ei_missing_idb);
}
proto_tree_add_item(block_data_tree, hf_pcapng_interface_id, tvb, offset, 4, encoding);
interface_id = tvb_get_guint32(tvb, offset, encoding);
if (interface_id >= wmem_array_get_count(info->interfaces)) {
expert_add_info(pinfo, block_tree, &ei_missing_idb);
}
offset += 4;
pcapng_add_timestamp(block_data_tree, pinfo, tvb, offset, encoding, interface_id, info);