Skip to content

Commit b179fbe

Browse files
Enrique GiraldoAndersBroman
authored andcommitted
ZigBee: Fix multiple wrong field type string in ZCL SE.
Replacing FT_STRING with FT_UINT_STRING and removing length field where it existed. Change-Id: I5dc8b8ba472f161d604e4c157a9b0230694ea87a Reviewed-on: https://code.wireshark.org/review/37463 Reviewed-by: Kenneth Soerensen <[email protected]> Petri-Dish: Anders Broman <[email protected]> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <[email protected]>
1 parent 4dc64b4 commit b179fbe

File tree

1 file changed

+17
-60
lines changed

1 file changed

+17
-60
lines changed

epan/dissectors/packet-zbee-zcl-se.c

Lines changed: 17 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,6 @@ static int hf_zbee_zcl_price_tariff_resolution_period = -1;
15141514
static int hf_zbee_zcl_price_cpp_auth = -1;
15151515
static int hf_zbee_zcl_price_cpp_price_tier= -1;
15161516
static int hf_zbee_zcl_price_rate_label = -1;
1517-
static int hf_zbee_zcl_price_rate_label_length = -1;
15181517
static int hf_zbee_zcl_price_unit_of_measure = -1;
15191518
static int hf_zbee_zcl_price_currency = -1;
15201519
static int hf_zbee_zcl_price_trailing_digit_and_price_tier = -1;
@@ -2254,10 +2253,9 @@ dissect_zcl_price_get_credit_payment(tvbuff_t *tvb, proto_tree *tree, guint *off
22542253
static void
22552254
dissect_zcl_price_publish_price(tvbuff_t *tvb, proto_tree *tree, guint *offset)
22562255
{
2257-
guint rate_label_len;
2258-
guint8 *rate_label_data;
22592256
nstime_t start_time;
22602257
nstime_t current_time;
2258+
int length;
22612259

22622260
static const int * trailing_digit[] = {
22632261
&hf_zbee_zcl_price_tier,
@@ -2280,15 +2278,9 @@ dissect_zcl_price_publish_price(tvbuff_t *tvb, proto_tree *tree, guint *offset)
22802278
proto_tree_add_item(tree, hf_zbee_zcl_price_provider_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
22812279
*offset += 4;
22822280

2283-
/* Rate Label Length */
2284-
rate_label_len = tvb_get_guint8(tvb, *offset); /* string length */
2285-
proto_tree_add_item(tree, hf_zbee_zcl_price_rate_label_length, tvb, *offset, 1, ENC_NA);
2286-
*offset += 1;
2287-
22882281
/* Rate Label */
2289-
rate_label_data = tvb_get_string_enc(wmem_packet_scope(), tvb, *offset, rate_label_len, ENC_LITTLE_ENDIAN);
2290-
proto_tree_add_string(tree, hf_zbee_zcl_price_rate_label, tvb, *offset, rate_label_len, rate_label_data);
2291-
*offset += rate_label_len;
2282+
proto_tree_add_item_ret_length(tree, hf_zbee_zcl_price_rate_label, tvb, *offset, 1, ENC_NA | ENC_ZIGBEE, &length);
2283+
*offset += length;
22922284

22932285
/* Issuer Event ID */
22942286
proto_tree_add_item(tree, hf_zbee_zcl_price_issuer_event_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
@@ -3212,12 +3204,8 @@ proto_register_zbee_zcl_price(void)
32123204
{ "CPP Auth", "zbee_zcl_se.price.cpp_auth", FT_UINT8, BASE_DEC, NULL,
32133205
0x00, NULL, HFILL } },
32143206

3215-
{ &hf_zbee_zcl_price_rate_label_length,
3216-
{ "Rate Label Length", "zbee_zcl_se.price.rate_label.length", FT_UINT8, BASE_DEC, NULL,
3217-
0x00, NULL, HFILL } },
3218-
32193207
{ &hf_zbee_zcl_price_rate_label,
3220-
{ "Rate Label", "zbee_zcl_se.price.rate_label", FT_STRING, BASE_NONE, NULL,
3208+
{ "Rate Label", "zbee_zcl_se.price.rate_label", FT_UINT_STRING, BASE_NONE, NULL,
32213209
0x00, NULL, HFILL } },
32223210

32233211
{ &hf_zbee_zcl_price_unit_of_measure,
@@ -3521,7 +3509,7 @@ proto_register_zbee_zcl_price(void)
35213509
0x00, NULL, HFILL } },
35223510

35233511
{ &hf_zbee_zcl_price_tier_labels_tier_label,
3524-
{ "Tariff Label", "zbee_zcl_se.price.tier_labels.tier_label", FT_STRING, BASE_NONE, NULL,
3512+
{ "Tariff Label", "zbee_zcl_se.price.tier_labels.tier_label", FT_UINT_STRING, BASE_NONE, NULL,
35253513
0x00, NULL, HFILL } },
35263514

35273515
{ &hf_zbee_zcl_price_billing_period_start_time,
@@ -3581,7 +3569,7 @@ proto_register_zbee_zcl_price(void)
35813569
0x00, NULL, HFILL } },
35823570

35833571
{ &hf_zbee_zcl_price_credit_payment_ref,
3584-
{ "Credit Payment Ref", "zbee_zcl_se.price.credit_payment.ref", FT_STRING, BASE_NONE, NULL,
3572+
{ "Credit Payment Ref", "zbee_zcl_se.price.credit_payment.ref", FT_UINT_STRING, BASE_NONE, NULL,
35853573
0x00, NULL, HFILL } },
35863574

35873575
{ &hf_zbee_zcl_price_old_currency,
@@ -8023,12 +8011,10 @@ static int hf_zbee_zcl_msg_ext_ctrl = -1;
80238011
static int hf_zbee_zcl_msg_ext_ctrl_status = -1;
80248012
static int hf_zbee_zcl_msg_start_time = -1;
80258013
static int hf_zbee_zcl_msg_duration = -1;
8026-
static int hf_zbee_zcl_msg_message_length = - 1;
80278014
static int hf_zbee_zcl_msg_message = -1;
80288015
static int hf_zbee_zcl_msg_confirm_time = -1;
80298016
static int hf_zbee_zcl_msg_confirm_ctrl = -1;
80308017
static int hf_zbee_zcl_msg_confirm_response = -1;
8031-
static int hf_zbee_zcl_msg_confirm_response_length = - 1;
80328018
static int hf_zbee_zcl_msg_implementation_time = -1;
80338019
static int hf_zbee_zcl_msg_earliest_time = -1;
80348020

@@ -8170,7 +8156,6 @@ static void
81708156
dissect_zcl_msg_display(tvbuff_t *tvb, proto_tree *tree, guint *offset)
81718157
{
81728158
guint msg_len;
8173-
guint8 *msg_data;
81748159

81758160
static const int * message_ctrl_flags[] = {
81768161
&hf_zbee_zcl_msg_ctrl_tx,
@@ -8202,14 +8187,8 @@ dissect_zcl_msg_display(tvbuff_t *tvb, proto_tree *tree, guint *offset)
82028187
proto_tree_add_item(tree, hf_zbee_zcl_msg_duration, tvb, *offset, 2, ENC_LITTLE_ENDIAN);
82038188
*offset += 2;
82048189

8205-
/* Message Length */
8206-
msg_len = tvb_get_guint8(tvb, *offset); /* string length */
8207-
proto_tree_add_item(tree, hf_zbee_zcl_msg_message_length, tvb, *offset, 1, ENC_NA);
8208-
*offset += 1;
8209-
82108190
/* Message */
8211-
msg_data = tvb_get_string_enc(wmem_packet_scope(), tvb, *offset, msg_len, ENC_LITTLE_ENDIAN);
8212-
proto_tree_add_string(tree, hf_zbee_zcl_msg_message, tvb, *offset, msg_len, msg_data);
8191+
proto_tree_add_item_ret_length(tree, hf_zbee_zcl_msg_message, tvb, *offset, 1, ENC_NA | ENC_ZIGBEE, &msg_len);
82138192
*offset += msg_len;
82148193

82158194
/* (Optional) Extended Message Control */
@@ -8298,7 +8277,6 @@ static void
82988277
dissect_zcl_msg_confirm(tvbuff_t *tvb, proto_tree *tree, guint *offset)
82998278
{
83008279
guint msg_len;
8301-
guint8 *msg_data;
83028280
nstime_t confirm_time;
83038281

83048282
/* Message ID */
@@ -8316,19 +8294,10 @@ dissect_zcl_msg_confirm(tvbuff_t *tvb, proto_tree *tree, guint *offset)
83168294
proto_tree_add_item(tree, hf_zbee_zcl_msg_confirm_ctrl, tvb, *offset, 1, ENC_NA);
83178295
*offset += 1;
83188296

8319-
/* (Optional) Response Text Length */
8320-
if ( tvb_reported_length_remaining(tvb, *offset) <= 0 ) return;
8321-
msg_len = tvb_get_guint8(tvb, *offset); /* string length */
8322-
proto_tree_add_item(tree, hf_zbee_zcl_msg_confirm_response_length, tvb, *offset, 1, ENC_NA);
8323-
*offset += 1;
8324-
83258297
/* (Optional) Response Text, but is we have a length we expect to find the subsequent string */
8326-
if (msg_len > 0) {
8327-
msg_data = tvb_get_string_enc(wmem_packet_scope(), tvb, *offset, msg_len, ENC_LITTLE_ENDIAN);
8328-
proto_tree_add_string(tree, hf_zbee_zcl_msg_confirm_response, tvb, *offset, msg_len, msg_data);
8329-
*offset += msg_len;
8330-
}
8331-
8298+
if ( tvb_reported_length_remaining(tvb, *offset) <= 0 ) return;
8299+
proto_tree_add_item_ret_length(tree, hf_zbee_zcl_msg_confirm_response, tvb, *offset, 1, ENC_NA | ENC_ZIGBEE, &msg_len);
8300+
*offset += msg_len;
83328301
} /* dissect_zcl_msg_confirm */
83338302

83348303
/**
@@ -8431,12 +8400,8 @@ proto_register_zbee_zcl_msg(void)
84318400
{ "Duration", "zbee_zcl_se.msg.message.duration", FT_UINT16, BASE_CUSTOM, CF_FUNC(decode_zcl_msg_duration),
84328401
0x00, NULL, HFILL } },
84338402

8434-
{ &hf_zbee_zcl_msg_message_length,
8435-
{ "Message Length", "zbee_zcl_se.msg.message.length", FT_UINT8, BASE_DEC, NULL,
8436-
0x00, NULL, HFILL } },
8437-
84388403
{ &hf_zbee_zcl_msg_message,
8439-
{ "Message", "zbee_zcl_se.msg.message", FT_STRING, BASE_NONE, NULL,
8404+
{ "Message", "zbee_zcl_se.msg.message", FT_UINT_STRING, BASE_NONE, NULL,
84408405
0x00, NULL, HFILL } },
84418406

84428407
{ &hf_zbee_zcl_msg_confirm_time,
@@ -8447,12 +8412,8 @@ proto_register_zbee_zcl_msg(void)
84478412
{ "Confirmation Control", "zbee_zcl_se.msg.message.confirm.ctrl", FT_BOOLEAN, 8, TFS(&tfs_no_yes),
84488413
ZBEE_ZCL_MSG_CONFIRM_CTRL_MASK, NULL, HFILL } },
84498414

8450-
{ &hf_zbee_zcl_msg_confirm_response_length,
8451-
{ "Response Length", "zbee_zcl_se.msg.message.length", FT_UINT8, BASE_DEC, NULL,
8452-
0x00, NULL, HFILL } },
8453-
84548415
{ &hf_zbee_zcl_msg_confirm_response,
8455-
{ "Response", "zbee_zcl_se.msg.message", FT_STRING, BASE_NONE, NULL,
8416+
{ "Response", "zbee_zcl_se.msg.message", FT_UINT_STRING, BASE_NONE, NULL,
84568417
0x00, NULL, HFILL } },
84578418

84588419
{ &hf_zbee_zcl_msg_implementation_time,
@@ -11971,7 +11932,7 @@ proto_register_zbee_zcl_calendar(void)
1197111932
0x00, NULL, HFILL } },
1197211933

1197311934
{ &hf_zbee_zcl_calendar_name,
11974-
{ "Calendar Name", "zbee_zcl_se.calendar.name", FT_STRING, BASE_NONE, NULL,
11935+
{ "Calendar Name", "zbee_zcl_se.calendar.name", FT_UINT_STRING, BASE_NONE, NULL,
1197511936
0x00, NULL, HFILL } },
1197611937

1197711938
{ &hf_zbee_zcl_calendar_command_index,
@@ -12363,8 +12324,7 @@ static void
1236312324
dissect_zcl_daily_schedule_publish_schedule(tvbuff_t *tvb, proto_tree *tree, guint *offset)
1236412325
{
1236512326
nstime_t start_time;
12366-
guint msg_len;
12367-
guint8 *msg_data;
12327+
int length;
1236812328

1236912329
/* Provider Id */
1237012330
proto_tree_add_item(tree, hf_zbee_zcl_daily_schedule_provider_id, tvb, *offset, 4, ENC_LITTLE_ENDIAN);
@@ -12393,11 +12353,8 @@ dissect_zcl_daily_schedule_publish_schedule(tvbuff_t *tvb, proto_tree *tree, gui
1239312353
*offset += 1;
1239412354

1239512355
/* Schedule Name */
12396-
msg_len = tvb_get_guint8(tvb, *offset); /* string length */
12397-
*offset += 1;
12398-
msg_data = tvb_get_string_enc(wmem_packet_scope(), tvb, *offset, msg_len, ENC_LITTLE_ENDIAN);
12399-
proto_tree_add_string(tree, hf_zbee_zcl_daily_schedule_name, tvb, *offset, msg_len, msg_data);
12400-
*offset += msg_len;
12356+
proto_tree_add_item_ret_length(tree, hf_zbee_zcl_daily_schedule_name, tvb, *offset, 1, ENC_NA | ENC_ZIGBEE, &length);
12357+
*offset += length;
1240112358
} /*dissect_zcl_daily_schedule_publish_schedule*/
1240212359

1240312360
/**
@@ -12594,7 +12551,7 @@ proto_register_zbee_zcl_daily_schedule(void)
1259412551
0x00, NULL, HFILL } },
1259512552

1259612553
{ &hf_zbee_zcl_daily_schedule_name,
12597-
{ "Schedule Name", "zbee_zcl_se.daily_schedule.name", FT_STRING, BASE_NONE, NULL,
12554+
{ "Schedule Name", "zbee_zcl_se.daily_schedule.name", FT_UINT_STRING, BASE_NONE, NULL,
1259812555
0x00, NULL, HFILL } },
1259912556

1260012557
{ &hf_zbee_zcl_daily_schedule_command_index,

0 commit comments

Comments
 (0)