Create protocols to the end of the TVB if length unknown upfront

Creating protocols with unknown length must be created to the end of the TVB
first and reined back using proto_set_len() once the length becomes known.
Not doing so can make indentification of problems harder and prevents analysis
engines like MATE from properly processing the generated protocol trees.
With this change the remaining offending dissectors are corrected for this.

Closes #16961
This commit is contained in:
Jaap Keuter 2020-10-28 12:02:29 +01:00 committed by Wireshark GitLab Utility
parent af0c4203a0
commit 918db88055
8 changed files with 10 additions and 10 deletions

View File

@ -53,7 +53,7 @@ dissect_aruba_adp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
if (tree) {
ti = proto_tree_add_item(tree, proto_aruba_adp, tvb, 0, 0, ENC_NA);
ti = proto_tree_add_item(tree, proto_aruba_adp, tvb, 0, -1, ENC_NA);
aruba_adp_tree = proto_item_add_subtree(ti, ett_aruba_adp);
}

View File

@ -272,7 +272,7 @@ dissect_sm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
col_add_fstr(pinfo->cinfo, COL_INFO, "Cisco SM Packet (%s)",
val_to_str_const(sm_message_type, sm_message_type_value_info,"reserved"));
ti = proto_tree_add_item(tree, proto_sm, tvb, offset, 0, ENC_NA);
ti = proto_tree_add_item(tree, proto_sm, tvb, offset, -1, ENC_NA);
sm_tree = proto_item_add_subtree(ti, ett_sm);
proto_tree_add_uint_format_value(sm_tree, hf_sm_sm_msg_type, tvb, offset, 4, sm_message_type,

View File

@ -2940,7 +2940,7 @@ dissect_f5ethtrailer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
tdata->tmm = F5ETH_TAP_TMM_MAX;
if (tree) {
trailer_item = proto_tree_add_item(tree, proto_f5ethtrailer, tvb, offset, 0, ENC_NA);
trailer_item = proto_tree_add_item(tree, proto_f5ethtrailer, tvb, offset, -1, ENC_NA);
tree = proto_item_add_subtree(trailer_item, ett_f5ethtrailer);
if (has_fcs) {
proto_tree_add_item(tree, hf_orig_fcs, tvb, offset - 4, 4, ENC_NA);

View File

@ -488,7 +488,7 @@ static int dissect_mgcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
num_messages++;
/* Create our mgcp subtree */
ti = proto_tree_add_item(tree, proto_mgcp, tvb, 0, 0, ENC_NA);
ti = proto_tree_add_item(tree, proto_mgcp, tvb, 0, -1, ENC_NA);
mgcp_tree = proto_item_add_subtree(ti, ett_mgcp);
sectionlen = tvb_find_dot_line(tvb, tvb_sectionbegin, -1, &tvb_sectionend);

View File

@ -737,7 +737,7 @@ dissect_mtp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
pref_mtp3_standard = mtp3_standard;
mtp3_item = proto_tree_add_item(tree, proto_mtp3, tvb, 0, 0, ENC_NA);
mtp3_item = proto_tree_add_item(tree, proto_mtp3, tvb, 0, -1, ENC_NA);
si = tvb_get_guint8(tvb, SIO_OFFSET) & SERVICE_INDICATOR_MASK;
if (mtp3_heuristic_standard) {

View File

@ -278,7 +278,7 @@ dissect_pcomascii(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint8 op_size;
/* Create protocol tree */
ti = proto_tree_add_item(tree, proto_pcomascii, tvb, offset, 0, ENC_NA);
ti = proto_tree_add_item(tree, proto_pcomascii, tvb, offset, -1, ENC_NA);
pcomascii_tree = proto_item_add_subtree(ti, ett_pcomascii);
if (pinfo->srcport == global_pcomtcp_tcp_port ){ // Reply
@ -429,7 +429,7 @@ dissect_pcombinary(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
const gchar* command_str;
/* Create protocol tree */
ti = proto_tree_add_item(tree, proto_pcombinary, tvb, offset, 0, ENC_NA);
ti = proto_tree_add_item(tree, proto_pcombinary, tvb, offset, -1, ENC_NA);
pcombinary_tree = proto_item_add_subtree(ti, ett_pcombinary);
proto_tree_add_item(pcombinary_tree, hf_pcombinary_stx, tvb,

View File

@ -154,7 +154,7 @@ dissect_pflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
col_set_str(pinfo->cinfo, COL_PROTOCOL, "PFLOG");
ti = proto_tree_add_item(tree, proto_pflog, tvb, offset, 0, ENC_NA);
ti = proto_tree_add_item(tree, proto_pflog, tvb, offset, -1, ENC_NA);
pflog_tree = proto_item_add_subtree(ti, ett_pflog);
length = tvb_get_guint8(tvb, offset) + pad_len;
@ -414,7 +414,7 @@ dissect_old_pflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
col_set_str(pinfo->cinfo, COL_PROTOCOL, "PFLOG-OLD");
ti = proto_tree_add_item(tree, proto_old_pflog, tvb, 0, 0, ENC_NA);
ti = proto_tree_add_item(tree, proto_old_pflog, tvb, 0, -1, ENC_NA);
pflog_tree = proto_item_add_subtree(ti, ett_pflog);
proto_tree_add_item(pflog_tree, hf_old_pflog_af, tvb, offset, 4, ENC_BIG_ENDIAN);

View File

@ -450,7 +450,7 @@ dissect_wtp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
fprintf(stderr, "dissect_wtp: cbHeader = %d\n", cbHeader);
#endif
/* NOTE - Length will be set when we process the TPI */
ti = proto_tree_add_item(tree, proto_wtp, tvb, offCur, 0, ENC_NA);
ti = proto_tree_add_item(tree, proto_wtp, tvb, offCur, -1, ENC_NA);
#ifdef DEBUG
fprintf(stderr, "dissect_wtp: (7) Returned from proto_tree_add_item\n");
#endif