diff options
author | Andreas Leibold <andreas.leibold@harman.com> | 2016-08-22 12:51:05 +0200 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-08-22 12:56:57 +0000 |
commit | 22e421f7d390e7558b998dc458bfb536cfaf460b (patch) | |
tree | ab5f2af6491f22b7cf0e28c8850fba8b7469e79e /epan/dissectors/packet-ieee1722.c | |
parent | b9e70e9b4cb0d85b6fcbbcfa387a5bea80046665 (diff) |
Fixed a bug which might have caused a division by 0.
Variable "channels_per_frame" could have caused a division by 0.
This is now changed, by stopping dissection in this case. A warning is
shown for this case.
Change-Id: I6d4dcb91b833a7d7f0759e28f56950b94ab1ed7e
Reviewed-on: https://code.wireshark.org/review/17228
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-ieee1722.c')
-rw-r--r-- | epan/dissectors/packet-ieee1722.c | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/epan/dissectors/packet-ieee1722.c b/epan/dissectors/packet-ieee1722.c index d03936a2c6..6d3f075cae 100644 --- a/epan/dissectors/packet-ieee1722.c +++ b/epan/dissectors/packet-ieee1722.c @@ -1071,40 +1071,43 @@ static int dissect_1722_aaf (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree { expert_add_info(pinfo, ti_channels_per_frame, &ei_aaf_channels_per_frame); } - offset += 2; - ti = proto_tree_add_item_ret_uint(ti_aaf_tree, hf_1722_aaf_bit_depth, tvb, offset, 1, ENC_BIG_ENDIAN, &bit_depth); - if ((bit_depth == 0) || (bit_depth > sample_width)) + else { - expert_add_info(pinfo, ti, &ei_aaf_incorrect_bit_depth); - } - offset += 1; - ti = proto_tree_add_item_ret_uint(ti_aaf_tree, hf_1722_aaf_stream_data_length, tvb, offset, 2, ENC_BIG_ENDIAN, &datalen); - proto_item_append_text(ti, " bytes"); - offset += 2; + offset += 2; + ti = proto_tree_add_item_ret_uint(ti_aaf_tree, hf_1722_aaf_bit_depth, tvb, offset, 1, ENC_BIG_ENDIAN, &bit_depth); + if ((bit_depth == 0) || (bit_depth > sample_width)) + { + expert_add_info(pinfo, ti, &ei_aaf_incorrect_bit_depth); + } + offset += 1; + ti = proto_tree_add_item_ret_uint(ti_aaf_tree, hf_1722_aaf_stream_data_length, tvb, offset, 2, ENC_BIG_ENDIAN, &datalen); + proto_item_append_text(ti, " bytes"); + offset += 2; - proto_tree_add_bitmask_list(ti_aaf_tree, tvb, offset, 1, fields_pcm, ENC_BIG_ENDIAN); - offset += 2; + proto_tree_add_bitmask_list(ti_aaf_tree, tvb, offset, 1, fields_pcm, ENC_BIG_ENDIAN); + offset += 2; - /* Make the Audio sample tree. */ - ti = proto_tree_add_item(ti_aaf_tree, hf_1722_aaf_data, tvb, offset, datalen, ENC_NA); - ti_audio_tree = proto_item_add_subtree(ti, ett_1722_aaf_audio); + /* Make the Audio sample tree. */ + ti = proto_tree_add_item(ti_aaf_tree, hf_1722_aaf_data, tvb, offset, datalen, ENC_NA); + ti_audio_tree = proto_item_add_subtree(ti, ett_1722_aaf_audio); - if (sample_width == 0 || channels_per_frame == 0) - { - expert_add_info(pinfo, ti, &ei_aaf_sample_width); - } - else - { - /* Loop through all samples and add them to the audio tree. */ - for (j = 0; j < ((datalen * 8) / (channels_per_frame * sample_width)); j++) + if (sample_width == 0) { - ti_sample_tree = proto_tree_add_subtree_format(ti_audio_tree, tvb, offset, 1, - ett_1722_aaf_sample, NULL, "Sample Chunk %d", j); - for (i = 0; i < channels_per_frame; i++) + expert_add_info(pinfo, ti, &ei_aaf_sample_width); + } + else + { + /* Loop through all samples and add them to the audio tree. */ + for (j = 0; j < ((datalen * 8) / (channels_per_frame * sample_width)); j++) { - ti = proto_tree_add_item(ti_sample_tree, hf_1722_aaf_sample, tvb, offset, sample_width / 8, ENC_NA); - proto_item_prepend_text(ti, "Channel: %d ", i); - offset += (sample_width / 8); + ti_sample_tree = proto_tree_add_subtree_format(ti_audio_tree, tvb, offset, 1, + ett_1722_aaf_sample, NULL, "Sample Chunk %d", j); + for (i = 0; i < channels_per_frame; i++) + { + ti = proto_tree_add_item(ti_sample_tree, hf_1722_aaf_sample, tvb, offset, sample_width / 8, ENC_NA); + proto_item_prepend_text(ti, "Channel: %d ", i); + offset += (sample_width / 8); + } } } } |