diff options
author | Triton Circonflexe <triton@kumal.info> | 2024-02-24 21:59:30 +0100 |
---|---|---|
committer | AndersBroman <a.broman58@gmail.com> | 2024-02-27 08:45:02 +0000 |
commit | 9840e6247f2807e7c2b83dd3a3a9d1ca1886c876 (patch) | |
tree | 51fe8ba7a80693f18f2033dec4c7072c3f7816e1 /epan | |
parent | 4eaf10bc4e46762b1e304baf188d0767907e1914 (diff) |
Thrift: Align the endianness for double
Compact protocol uses little endian doubles instead of big endian like compact.
This issue is documented as an accident that became the de-facto standard.
For consistency, the sub-tvbuff_t given to delegated sub-dissectors is aligned
with binary protocol to allow a sub-dissector to work with both binary and compact.
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-thrift.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/epan/dissectors/packet-thrift.c b/epan/dissectors/packet-thrift.c index 6b198f19fd..5205f18e7c 100644 --- a/epan/dissectors/packet-thrift.c +++ b/epan/dissectors/packet-thrift.c @@ -1265,7 +1265,22 @@ dissect_thrift_raw_double(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, i thrift_opt->use_std_dissector = TRUE; if (raw_dissector != NULL) { - tvbuff_t* sub_tvb = tvb_new_subset_length(tvb, offset, TBP_THRIFT_DOUBLE_LEN); + tvbuff_t* sub_tvb; + if (thrift_opt->tprotocol & PROTO_THRIFT_COMPACT) { + /* Create a sub-tvbuff_t in big endian format as documented. */ + guint8 *data = wmem_alloc(wmem_packet_scope(), TBP_THRIFT_DOUBLE_LEN); + data[0] = tvb_get_guint8(tvb, offset + 7); + data[1] = tvb_get_guint8(tvb, offset + 6); + data[2] = tvb_get_guint8(tvb, offset + 5); + data[3] = tvb_get_guint8(tvb, offset + 4); + data[4] = tvb_get_guint8(tvb, offset + 3); + data[5] = tvb_get_guint8(tvb, offset + 2); + data[6] = tvb_get_guint8(tvb, offset + 1); + data[7] = tvb_get_guint8(tvb, offset); + sub_tvb = tvb_new_child_real_data(tvb, data, TBP_THRIFT_DOUBLE_LEN, TBP_THRIFT_DOUBLE_LEN); + } else { + sub_tvb = tvb_new_subset_length(tvb, offset, TBP_THRIFT_DOUBLE_LEN); + } thrift_opt->use_std_dissector = FALSE; raw_dissector(sub_tvb, pinfo, tree, thrift_opt); } |