aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors
diff options
context:
space:
mode:
authorTriton Circonflexe <triton@kumal.info>2024-02-12 06:09:18 +0100
committerAndersBroman <a.broman58@gmail.com>2024-02-18 20:26:30 +0000
commite248d370360a5c73148d7beb4a5575bc35559dba (patch)
treeaae820194078c28d708828894e13058a67b7dc09 /epan/dissectors
parent268e7425416f0f482bc001c0ca8010c425db49c9 (diff)
Thrift: always generate field_id proto item
In order to report non-matching field id, the sub-dissector requires the proto_item element for the field id to be created, even if the tree is not.
Diffstat (limited to 'epan/dissectors')
-rw-r--r--epan/dissectors/packet-thrift.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/epan/dissectors/packet-thrift.c b/epan/dissectors/packet-thrift.c
index 8435524b34..7cee20fa01 100644
--- a/epan/dissectors/packet-thrift.c
+++ b/epan/dissectors/packet-thrift.c
@@ -651,10 +651,27 @@ dissect_thrift_field_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
expert_add_info(pinfo, header->fid_pi, &ei_thrift_unordered_field_id);
}
}
- } else if (header->fid_length <= 0) {
- /* Varint for field id was too long to decode, handle the error without the sub-tree. */
- proto_tree_add_expert(tree, pinfo, &ei_thrift_varint_too_large, tvb, header->fid_offset, TCP_THRIFT_MAX_I16_LEN);
- return THRIFT_REQUEST_REASSEMBLY;
+ } else {
+ /* The fid_pi value (proto_item for field_id) is required for sub-dissectors.
+ * Create it even in the absence of tree. */
+ if (delta == TCP_THRIFT_DELTA_NOT_SET) {
+ if (header->fid_length > 0) {
+ header->fid_pi = proto_tree_add_item(header->fh_tree, hf_thrift_fid, tvb, header->fid_offset, header->fid_length, ENC_BIG_ENDIAN);
+ } else {
+ /* Varint for field id was too long to decode, handle the error without the sub-tree. */
+ proto_tree_add_expert(tree, pinfo, &ei_thrift_varint_too_large, tvb, header->fid_offset, TCP_THRIFT_MAX_I16_LEN);
+ return THRIFT_REQUEST_REASSEMBLY;
+ }
+ } else {
+ if ((gint64)INT16_MIN > header->field_id || header->field_id > (gint64)INT16_MAX) {
+ header->fid_pi = proto_tree_add_int64(header->fh_tree, hf_thrift_i64, tvb, header->fid_offset, header->fid_length, header->field_id);
+ expert_add_info(pinfo, header->fid_pi, &ei_thrift_varint_too_large);
+ /* We continue anyway as the field id was displayed successfully. */
+ } else {
+ header->fid_pi = proto_tree_add_int(header->fh_tree, hf_thrift_fid, tvb, header->fid_offset, header->fid_length, (gint16)header->field_id);
+ }
+ proto_item_set_generated(header->fid_pi);
+ }
}
return *offset;