Fix use of _ret_uint() for UINT_{BYTES,STRING} when _ret_length() is wanted

_ret_uint() doesn't work for UNIT_BYTES and UINT_STRING. In these cases,
what was wanted was the total length in order to increment the offset.
(Note _ret_length() includes the fixed width length field; these were
written wanting only the value in the length field, not the total length.)

Change-Id: I9c7c2bc644c414d02eec3fff481e8863778f51fa
Reviewed-on: https://code.wireshark.org/review/38006
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
This commit is contained in:
John Thacker 2020-07-31 08:33:26 -04:00 committed by Alexis La Goutte
parent a44bdf5675
commit 0334b6af55
2 changed files with 11 additions and 13 deletions

View File

@ -2368,23 +2368,21 @@ dissect_lcp_auth_opt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
proto_item *tf;
guint32 id_len;
int offset = 0;
int length = tvb_reported_length(tvb);
int length;
if (!dissect_lcp_var_opt(tvb, pinfo, tree, proto_lcp_option_auth, ett_lcp_auth_opt, 3,
&field_tree, &tf))
return tvb_captured_length(tvb);
proto_tree_add_item_ret_uint(field_tree, hf_lcp_opt_id, tvb, offset + 2, 1, ENC_BIG_ENDIAN, &id_len);
offset += 2;
proto_tree_add_item_ret_length(field_tree, hf_lcp_opt_id, tvb, offset, 1, ENC_BIG_ENDIAN, &id_len);
if (length > 3) {
length -= 3;
offset += 3;
if ((int)id_len < length) {
length -= id_len;
offset += id_len;
proto_tree_add_item(field_tree, hf_lcp_opt_data, tvb, offset,
length, ENC_NA);
}
length = tvb_reported_length_remaining(tvb, offset);
if ((int)id_len < length) {
length -= id_len;
offset += id_len;
proto_tree_add_item(field_tree, hf_lcp_opt_data, tvb, offset,
length, ENC_NA);
}
return tvb_captured_length(tvb);
}

View File

@ -1048,8 +1048,8 @@ static int dissect_slsk_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
proto_tree_add_item(slsk_compr_packet_tree, hf_slsk_token, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN);
uncompr_tvb_offset += 4;
proto_tree_add_item_ret_uint(slsk_compr_packet_tree, hf_slsk_directory_name, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &len);
uncompr_tvb_offset += 4+len;
proto_tree_add_item_ret_length(slsk_compr_packet_tree, hf_slsk_directory_name, uncompr_tvb, uncompr_tvb_offset, 4, ENC_ASCII|ENC_LITTLE_ENDIAN, &len);
uncompr_tvb_offset += len;
proto_tree_add_item_ret_int(slsk_compr_packet_tree, hf_slsk_num_directories, uncompr_tvb, uncompr_tvb_offset, 4, ENC_LITTLE_ENDIAN, &j);
uncompr_tvb_offset += 4;