packet-bthci-cmd: For LE Supported Features, fix loop to exit after 8 items.

I haven't been able to find the appropriate spec, but either there is a
limit to the number of features bytes to add and this patch is needed,
or the (i < 8) part should be dropped.  As it is the other data and
expert info for 'unknown' fields will never be reached.

Detected by cppcheck:
epan/dissectors/packet-bthci_cmd.c:9183:72: warning: Condition 'i<8' is always true [knownConditionTrueFalse]
            while (tvb_captured_length_remaining(tvb, offset) > 0 && i < 8) {
                                                                       ^
epan/dissectors/packet-bthci_cmd.c:9181:25: note: Assignment 'i=0', assigned value is 0
            guint8  i = 0;
                        ^
epan/dissectors/packet-bthci_cmd.c:9183:72: note: Condition 'i<8' is always true
            while (tvb_captured_length_remaining(tvb, offset) > 0 && i < 8) {

Change-Id: Icfef0e9142a58aa1c525df9b7daf0aa820039167
Reviewed-on: https://code.wireshark.org/review/38049
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Martin Mathieson 2020-08-05 11:53:21 +01:00 committed by Anders Broman
parent 30413ed0b3
commit 75884bd011
1 changed files with 1 additions and 3 deletions

View File

@ -9178,9 +9178,7 @@ dissect_eir_ad_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bluetoo
break;
case 0x27: {/* LE Supported Features */
guint8 i = 0;
while (tvb_captured_length_remaining(tvb, offset) > 0 && i < 8) {
for (guint8 i=0; (tvb_captured_length_remaining(tvb, offset) > 0) && (i < 8); i++) {
proto_tree_add_bitmask(entry_tree, tvb, offset, hf_btcommon_eir_ad_le_features, ett_eir_ad_le_features, hfx_btcommon_eir_ad_le_features[i], ENC_NA);
offset += 1;
}