aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-thrift.c
diff options
context:
space:
mode:
authorAndersBroman <anders.broman@ericsson.com>2018-02-06 14:21:23 +0100
committerAnders Broman <a.broman58@gmail.com>2018-02-06 13:55:41 +0000
commit64c32c672c938b4a412fcb81d8e18447acf3cb3c (patch)
treef5aa81eaa847ebea3881a02556bf62fb7a452f81 /epan/dissectors/packet-thrift.c
parent41b571f9bdef6ea310fde062634245d3f48de8ea (diff)
[Thrift] Handle optional elememts in struct.
Change-Id: Iee494c299f8f10588146f0b41b759ce0272d9caf Reviewed-on: https://code.wireshark.org/review/25634 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-thrift.c')
-rw-r--r--epan/dissectors/packet-thrift.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/epan/dissectors/packet-thrift.c b/epan/dissectors/packet-thrift.c
index db50111769..6793a77b22 100644
--- a/epan/dissectors/packet-thrift.c
+++ b/epan/dissectors/packet-thrift.c
@@ -78,6 +78,7 @@ static int ett_thrift = -1;
static expert_field ei_thrift_wrong_type = EI_INIT;
static expert_field ei_thrift_struct_type_not_imp = EI_INIT;
+static expert_field ei_thrift_struct_type_not_in_seq = EI_INIT;
static const value_string thrift_type_vals[] = {
{ 0, "T_STOP" },
@@ -300,6 +301,18 @@ dissect_thrift_t_struct(tvbuff_t* tvb, packet_info* pinfo _U_, proto_tree* tree,
}
while (seq->fid) {
+ type = tvb_get_guint8(tvb, offset);
+ if (type != seq->type) {
+ /* Wrong field in sequence*/
+ if (seq->optional == TRUE) {
+ /* Skip to next element*/
+ seq++;
+ continue;
+ } else {
+ proto_tree_add_expert(sub_tree, pinfo, &ei_thrift_struct_type_not_in_seq, tvb, offset, 1);
+ return offset;
+ }
+ }
switch (seq->type) {
case DE_THRIFT_T_STOP:
offset = dissect_thrift_t_stop(tvb, pinfo, sub_tree, offset);
@@ -321,8 +334,10 @@ dissect_thrift_t_struct(tvbuff_t* tvb, packet_info* pinfo _U_, proto_tree* tree,
offset = dissect_thrift_t_i32(tvb, pinfo, sub_tree, offset, seq->fid, *seq->p_id);
break;
case DE_THRIFT_T_U64:
+ offset = dissect_thrift_t_u64(tvb, pinfo, sub_tree, offset, seq->fid, *seq->p_id);
+ break;
case DE_THRIFT_T_I64:
- proto_tree_add_expert(sub_tree, pinfo, &ei_thrift_struct_type_not_imp, tvb, offset, 1);
+ offset = dissect_thrift_t_i64(tvb, pinfo, sub_tree, offset, seq->fid, *seq->p_id);
break;
case DE_THRIFT_T_UTF7:
offset = dissect_thrift_t_utf7(tvb, pinfo, sub_tree, offset, seq->fid, *seq->p_id);
@@ -838,6 +853,7 @@ void proto_register_thrift(void) {
static ei_register_info ei[] = {
{ &ei_thrift_wrong_type,{ "thrift.wrong_type", PI_PROTOCOL, PI_ERROR, "Type value not expected", EXPFILL } },
{ &ei_thrift_struct_type_not_imp,{ "thrift.struct_type_not_imp", PI_PROTOCOL, PI_ERROR, "Struct type handling not implemented in Wireshak yet", EXPFILL } },
+ { &ei_thrift_struct_type_not_in_seq,{ "thrift.struct_type_not_in_seq", PI_PROTOCOL, PI_ERROR, "Wrong element in struct", EXPFILL } },
};