Skip to content

Commit

Permalink
GNW: Ensure that tvbuff proto data has the proper scope.
Browse files Browse the repository at this point in the history
Add security tvbuffs to our proto data using pinfo->pool.
Fixes #18779.
  • Loading branch information
geraldcombs committed Jan 6, 2023
1 parent 99385f1 commit 693dc40
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions epan/dissectors/packet-geonw.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ void proto_register_geonw(void);

#define TST_MAX 0xffffffff

#define SEC_TVB_KEY 0

/*
* Variables
*/
Expand Down Expand Up @@ -1910,7 +1912,7 @@ dissect_sec_payload(tvbuff_t *tvb, gint *offset, packet_info *pinfo, proto_tree
param_len = dissect_sec_var_len(tvb, offset, pinfo, field_tree);
if (param_len) {
tvbuff_t *next_tvb = tvb_new_subset_length(tvb, *offset, param_len);
p_add_proto_data(wmem_file_scope(), pinfo, proto_geonw, 0, next_tvb);
p_add_proto_data(pinfo->pool, pinfo, proto_geonw, SEC_TVB_KEY, next_tvb);
}
*offset += param_len;
break;
Expand Down Expand Up @@ -2113,7 +2115,7 @@ static int
dissect_sgeonw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *data _U_)
{
// Just store the tvbuff for later, as it is embedded inside a secured geonetworking packet
p_add_proto_data(wmem_file_scope(), pinfo, proto_geonw, 0, tvb);
p_add_proto_data(pinfo->pool, pinfo, proto_geonw, SEC_TVB_KEY, tvb);

return tvb_reported_length(tvb);
}
Expand Down Expand Up @@ -2226,7 +2228,7 @@ dissect_geonw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U

if (bh_next_header == BH_NH_SECURED_PKT) {
dissect_secured_message(tvb, offset, pinfo, geonw_tree, NULL);
tvbuff_t *next_tvb = (tvbuff_t*)p_get_proto_data(wmem_file_scope(), pinfo, proto_geonw, 0);
tvbuff_t *next_tvb = (tvbuff_t*)p_get_proto_data(pinfo->pool, pinfo, proto_geonw, SEC_TVB_KEY);
if (next_tvb) {
tvb = next_tvb;
bh_next_header = BH_NH_COMMON_HDR;
Expand Down Expand Up @@ -2259,7 +2261,6 @@ dissect_geonw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U
default:
hdr_len = -1;
}
p_add_proto_data(wmem_file_scope(), pinfo, proto_geonw, 0, NULL);
}
}

Expand Down

0 comments on commit 693dc40

Please sign in to comment.