ptvcursor: add explicit memory scope

I was hoping to avoid this, since the ptvcursor should already be
implicitly scoped to the tree it is working on. But there are a bunch of
call sites where the passed tree can be NULL (?) and a few places where
the tree is explicitly set/reset after creation, so requiring an
explicit scope is safer.

Avoids global memory pools in favour of ones the compiler can verify.
This commit is contained in:
Evan Huus 2021-09-15 12:09:18 -04:00 committed by Wireshark GitLab Utility
parent f4aa108913
commit e4b8a58513
21 changed files with 61 additions and 59 deletions

View File

@ -3015,7 +3015,7 @@ dissect_afs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
/* Process the packet according to what service it is */
/* Only for first packet in an rx data stream or the full reassembled stream */
if ( dissector && ( rxinfo->seq == 1 || reassembled ) ) {
cursor = ptvcursor_new(afs_op_tree, tvb, offset);
cursor = ptvcursor_new(pinfo->pool, afs_op_tree, tvb, offset);
(*dissector)(cursor, rxinfo, opcode);
}
}

View File

@ -263,7 +263,7 @@ static void dissect_a615a_protocol_file(tvbuff_t *tvb, packet_info *pinfo, proto
ti = proto_tree_add_string(a615a_tree, hf_a615a_file_type, tvb, 0, 0, a615a_file[suffix].full);
proto_item_set_generated(ti);
ptvcursor_t *ptvc = ptvcursor_new(a615a_tree, tvb, 0);
ptvcursor_t *ptvc = ptvcursor_new(pinfo->pool, a615a_tree, tvb, 0);
ptvcursor_add(ptvc, hf_a615a_file_length, 4, ENC_BIG_ENDIAN);
ptvcursor_add(ptvc, hf_a615a_protocol_version, 2, ENC_ASCII | ENC_NA);
@ -343,7 +343,7 @@ static int dissect_find(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
proto_item *ti = proto_tree_add_item(tree, proto_find, tvb, 0, -1, ENC_NA);
proto_tree *find_tree = proto_item_add_subtree(ti, ett_find);
ptvcursor_t *ptvc = ptvcursor_new(find_tree, tvb, 0);
ptvcursor_t *ptvc = ptvcursor_new(pinfo->pool, find_tree, tvb, 0);
guint32 opcode;
ptvcursor_add_ret_uint(ptvc, hf_find_opcode, 2, ENC_BIG_ENDIAN, &opcode);

View File

@ -87,7 +87,7 @@ dissect_brcm_tag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data
ti = proto_tree_add_item(tree, proto_brcm_tag, tvb, 0, -1, ENC_NA);
brcm_tag_tree = proto_item_add_subtree(ti, ett_brcm_tag);
cursor = ptvcursor_new(brcm_tag_tree, tvb, 0);
cursor = ptvcursor_new(pinfo->pool, brcm_tag_tree, tvb, 0);
/* Check if we have enough data to process the header */
if (check_tvb_length(cursor, BRCM_TAG_LEN) != TVB_LEN_SHORTEST) {

View File

@ -1181,7 +1181,7 @@ dissect_dbus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
proto_tree *dbus_tree = proto_item_add_subtree(pi, ett_dbus);
gint offset = 0;
packet.cursor = ptvcursor_new(dbus_tree, tvb, offset);
packet.cursor = ptvcursor_new(pinfo->pool, dbus_tree, tvb, offset);
(void)(dissect_dbus_header(&packet) ||
dissect_dbus_header_fields(&packet) ||

View File

@ -93,7 +93,7 @@ dissect_hdcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
tvb, 0, tvb_reported_length(tvb), "HDCP");
hdcp_tree = proto_item_add_subtree(pi, ett_hdcp);
cursor = ptvcursor_new(hdcp_tree, tvb, 0);
cursor = ptvcursor_new(pinfo->pool, hdcp_tree, tvb, 0);
if (pinfo->p2p_dir==P2P_DIR_SENT) {
/* transmitter sends data to the receiver */

View File

@ -156,7 +156,7 @@ dissect_hdcp2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U
pi = proto_tree_add_protocol_format(tree, proto_hdcp2,
tvb, 0, tvb_reported_length(tvb), "HDCP2");
hdcp_tree = proto_item_add_subtree(pi, ett_hdcp2);
cursor = ptvcursor_new(hdcp_tree, tvb, 0);
cursor = ptvcursor_new(pinfo->pool, hdcp_tree, tvb, 0);
col_append_str(pinfo->cinfo, COL_INFO,
val_to_str(msg_id, hdcp2_msg_id, "unknown (0x%x)"));

View File

@ -5982,7 +5982,7 @@ dissect_homeplug_av(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* d
ti = proto_tree_add_item(tree, proto_homeplug_av, tvb, 0, -1, ENC_NA);
homeplug_av_tree = proto_item_add_subtree(ti, ett_homeplug_av);
cursor = ptvcursor_new(homeplug_av_tree, tvb, 0);
cursor = ptvcursor_new(pinfo->pool, homeplug_av_tree, tvb, 0);
/* Check if we have enough data to process the header */
if (check_tvb_length(cursor, HOMEPLUG_AV_MMHDR_LEN) != TVB_LEN_SHORTEST) {

View File

@ -1301,7 +1301,7 @@ dissect_homeplug(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void* d
it = proto_tree_add_item(tree, proto_homeplug, tvb, homeplug_offset, -1, ENC_NA);
homeplug_tree = proto_item_add_subtree(it, ett_homeplug);
cursor = ptvcursor_new(homeplug_tree, tvb, 0);
cursor = ptvcursor_new(pinfo->pool, homeplug_tree, tvb, 0);
/* We do not have enough data to read mctrl field stop the dissection */
if (check_tvb_length(cursor, HOMEPLUG_MCTRL_LEN) != TVB_LEN_SHORTEST) {

View File

@ -2538,7 +2538,7 @@ static void dissect_mq_pdu(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree)
ptvcursor_t* cursor;
mq_tree = proto_tree_add_subtree(mqroot_tree, tvb, offset, iSizeCONN, ett_mq_conn, NULL, MQ_TEXT_CONN);
cursor = ptvcursor_new(mq_tree, tvb, offset);
cursor = ptvcursor_new(pinfo->pool, mq_tree, tvb, offset);
ptvcursor_add(cursor, hf_mq_conn_QMgr, 48, iEnc);
ptvcursor_add(cursor, hf_mq_conn_appname, 28, iEnc);

View File

@ -2481,7 +2481,7 @@ process_bitfield_sub_ptvc_record(ptvcursor_t *ptvc, const ptvc_record *rec,
sub_tree = proto_item_add_subtree(item, ett);
/* Make a new ptvcursor */
sub_ptvc = ptvcursor_new(sub_tree, ptvcursor_tvbuff(ptvc),
sub_ptvc = ptvcursor_new(wmem_packet_scope(), sub_tree, ptvcursor_tvbuff(ptvc),
current_offset);
/* Use it */
@ -2659,7 +2659,7 @@ process_ptvc_record(ptvcursor_t *ptvc, packet_info *pinfo, const ptvc_record *re
these records */
if (ncp_rec->expert_handler_func)
{
expert_ptvc = ptvcursor_new(expert_tree, expert_tvb, expert_offset);
expert_ptvc = ptvcursor_new(pinfo->pool, expert_tree, expert_tvb, expert_offset);
ncp_rec->expert_handler_func(expert_ptvc, pinfo, ncp_rec, request);
ptvcursor_free(expert_ptvc);
}
@ -6437,7 +6437,7 @@ dissect_ncp_8x20reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *volatile nc
if (request_value->req_mask & 0x0004) {
btree = proto_tree_add_subtree(atree, tvb, loffset, -1, ett_ncp, &bitem, "Attributes");
ptvc = ptvcursor_new(btree, tvb, loffset);
ptvc = ptvcursor_new(pinfo->pool, btree, tvb, loffset);
process_ptvc_record(ptvc, pinfo, ptvc_struct_attributes_struct,
NULL, TRUE, ncp_rec, FALSE);
ptvcursor_free(ptvc);
@ -6482,7 +6482,7 @@ dissect_ncp_8x20reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *volatile nc
/* Extended Attributes oldstyle location*/
if (request_value->req_mask & 0x0020 && !ncp_newstyle) {
btree = proto_tree_add_subtree(atree, tvb, loffset, -1, ett_ncp, &bitem, "Extended Attributes");
ptvc = ptvcursor_new(btree, tvb, loffset);
ptvc = ptvcursor_new(pinfo->pool, btree, tvb, loffset);
process_ptvc_record(ptvc, pinfo, ptvc_struct_ea_info_struct,
NULL, TRUE, ncp_rec, FALSE);
ptvcursor_free(ptvc);
@ -6499,7 +6499,7 @@ dissect_ncp_8x20reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *volatile nc
if (request_value->req_mask & 0x0020 && ncp_newstyle) {
btree = proto_tree_add_subtree(atree, tvb, loffset, -1, ett_ncp, &bitem, "Extended Attributes");
ptvc = ptvcursor_new(btree, tvb, loffset);
ptvc = ptvcursor_new(pinfo->pool, btree, tvb, loffset);
process_ptvc_record(ptvc, pinfo, ptvc_struct_ea_info_struct,
NULL, TRUE, ncp_rec, FALSE);
ptvcursor_free(ptvc);
@ -6515,7 +6515,7 @@ dissect_ncp_8x20reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *volatile nc
/* Archive Information */
if (request_value->req_mask & 0x0040) {
btree = proto_tree_add_subtree(atree, tvb, loffset, -1, ett_ncp, &bitem, "Archive");
ptvc = ptvcursor_new(btree, tvb, loffset);
ptvc = ptvcursor_new(pinfo->pool, btree, tvb, loffset);
process_ptvc_record(ptvc, pinfo, ptvc_struct_archive_info_struct,
NULL, TRUE, ncp_rec, FALSE);
ptvcursor_free(ptvc);
@ -6532,7 +6532,7 @@ dissect_ncp_8x20reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *volatile nc
if (request_value->req_mask & 0x0080) {
btree = proto_tree_add_subtree(atree, tvb, loffset, -1, ett_ncp, &bitem, "Modification");
ptvc = ptvcursor_new(btree, tvb, loffset);
ptvc = ptvcursor_new(pinfo->pool, btree, tvb, loffset);
process_ptvc_record(ptvc, pinfo, ptvc_struct_modify_info_struct,
NULL, TRUE, ncp_rec, FALSE);
ptvcursor_free(ptvc);
@ -6548,7 +6548,7 @@ dissect_ncp_8x20reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *volatile nc
/* Creation Information old style location */
if (request_value->req_mask & 0x0100 && !ncp_newstyle) {
btree = proto_tree_add_subtree(atree, tvb, loffset, -1, ett_ncp, &bitem, "Creation");
ptvc = ptvcursor_new(btree, tvb, loffset);
ptvc = ptvcursor_new(pinfo->pool, btree, tvb, loffset);
process_ptvc_record(ptvc, pinfo, ptvc_struct_creation_info_struct,
NULL, TRUE, ncp_rec, FALSE);
ptvcursor_free(ptvc);
@ -6564,7 +6564,7 @@ dissect_ncp_8x20reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *volatile nc
/* Creation Information new style location */
if (request_value->req_mask & 0x0100 && ncp_newstyle) {
btree = proto_tree_add_subtree(atree, tvb, loffset, -1, ett_ncp, &bitem, "Creation");
ptvc = ptvcursor_new(btree, tvb, loffset);
ptvc = ptvcursor_new(pinfo->pool, btree, tvb, loffset);
process_ptvc_record(ptvc, pinfo, ptvc_struct_creation_info_struct,
NULL, TRUE, ncp_rec, FALSE);
ptvcursor_free(ptvc);
@ -6591,7 +6591,7 @@ dissect_ncp_8x20reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *volatile nc
/* Directory Entry */
if (request_value->req_mask & 0x0400) {
btree = proto_tree_add_subtree(atree, tvb, loffset, -1, ett_ncp, &bitem, "Directory Entry");
ptvc = ptvcursor_new(btree, tvb, loffset);
ptvc = ptvcursor_new(pinfo->pool, btree, tvb, loffset);
process_ptvc_record(ptvc, pinfo, ptvc_struct_dir_entry_struct,
NULL, TRUE, ncp_rec, FALSE);
ptvcursor_free(ptvc);
@ -6606,7 +6606,7 @@ dissect_ncp_8x20reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *volatile nc
}
/* Rights Information */
if (request_value->req_mask & 0x0800) {
ptvc = ptvcursor_new(atree, tvb, loffset);
ptvc = ptvcursor_new(pinfo->pool, atree, tvb, loffset);
process_ptvc_record(ptvc, pinfo, ptvc_struct_rights_info_struct,
NULL, TRUE, ncp_rec, FALSE);
ptvcursor_free(ptvc);
@ -6675,7 +6675,7 @@ dissect_ncp_8x20reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *volatile nc
}
/* Flush Time */
if (request_value->req_mask_ext & 0x0004 && ncp_newstyle) {
ptvc = ptvcursor_new(atree, tvb, loffset);
ptvc = ptvcursor_new(pinfo->pool, atree, tvb, loffset);
process_ptvc_record(ptvc, pinfo, ptvc_struct_flush_time_struct,
NULL, TRUE, ncp_rec, FALSE);
ptvcursor_free(ptvc);
@ -6705,7 +6705,7 @@ dissect_ncp_8x20reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *volatile nc
if (request_value->req_mask_ext & 0x0080 && ncp_newstyle) {
btree = proto_tree_add_subtree(atree, tvb, loffset, -1, ett_ncp, &bitem, "Mac Date");
ptvc = ptvcursor_new(btree, tvb, loffset);
ptvc = ptvcursor_new(pinfo->pool, btree, tvb, loffset);
process_ptvc_record(ptvc, pinfo, ptvc_struct_mac_time_struct,
NULL, TRUE, ncp_rec, FALSE);
ptvcursor_free(ptvc);
@ -6714,7 +6714,7 @@ dissect_ncp_8x20reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *volatile nc
}
/* Last Access */
if (request_value->req_mask_ext & 0x0100 && ncp_newstyle) {
ptvc = ptvcursor_new(atree, tvb, loffset);
ptvc = ptvcursor_new(pinfo->pool, atree, tvb, loffset);
process_ptvc_record(ptvc, pinfo, ptvc_struct_last_access_time_struct,
NULL, TRUE, ncp_rec, FALSE);
ptvcursor_free(ptvc);
@ -7277,15 +7277,15 @@ dissect_ncp_request(tvbuff_t *tvb, packet_info *pinfo,
proto_tree_add_item(ncp_tree, hf_ncp_length, tvb, 7,
2, ENC_BIG_ENDIAN);
proto_tree_add_uint(ncp_tree, hf_ncp_subfunc, tvb, 9, 1, subfunc);
ptvc = ptvcursor_new(ncp_tree, tvb, 10);
ptvc = ptvcursor_new(pinfo->pool, ncp_tree, tvb, 10);
}
else {
proto_tree_add_uint(ncp_tree, hf_ncp_subfunc, tvb, 7, 1, subfunc);
ptvc = ptvcursor_new(ncp_tree, tvb, 8);
ptvc = ptvcursor_new(pinfo->pool, ncp_tree, tvb, 8);
}
}
else {
ptvc = ptvcursor_new(ncp_tree, tvb, 7);
ptvc = ptvcursor_new(pinfo->pool, ncp_tree, tvb, 7);
}
/* The group is not part of the packet, but it's useful
@ -8256,7 +8256,7 @@ dissect_ncp_reply(tvbuff_t *tvb, packet_info *pinfo,
req_cond_results = NULL;
}
clear_repeat_vars();
ptvc = ptvcursor_new(ncp_tree, tvb, 8);
ptvc = ptvcursor_new(pinfo->pool, ncp_tree, tvb, 8);
process_ptvc_record(ptvc, pinfo, ncp_rec->reply_ptvc,
req_cond_results, TRUE, ncp_rec, FALSE);
ptvcursor_free(ptvc);
@ -8444,7 +8444,7 @@ dissect_nds_request(tvbuff_t *tvb, packet_info *pinfo,
if (ncp_rec && ncp_rec->request_ptvc)
{
ptvc = ptvcursor_new(ncp_tree, tvb, 7);
ptvc = ptvcursor_new(pinfo->pool, ncp_tree, tvb, 7);
clear_repeat_vars();
process_ptvc_record(ptvc, pinfo, ncp_rec->request_ptvc, NULL, TRUE, ncp_rec, TRUE);
ptvcursor_free(ptvc);
@ -9524,7 +9524,7 @@ dissect_ping_req(tvbuff_t *tvb, packet_info *pinfo,
; /* nothing */
break;
}
ptvc = ptvcursor_new(ncp_tree, tvb, 7);
ptvc = ptvcursor_new(pinfo->pool, ncp_tree, tvb, 7);
if (ncp_rec && ncp_rec->request_ptvc) {
clear_repeat_vars();
process_ptvc_record(ptvc, pinfo, ncp_rec->request_ptvc, NULL, TRUE, ncp_rec, TRUE);

View File

@ -8025,7 +8025,7 @@ static void dissect_tlv_list(ptvcursor_t* ptvc, packet_info* pinfo, gint len)
{
// Create a sub buff with the correct length, so we can detect reading off the end
tvbuff_t* sub_tvbuff = tvb_new_subset_length(ptvcursor_tvbuff(ptvc), ptvcursor_current_offset(ptvc), tlv_len);
ptvcursor_t* sub_ptvc = ptvcursor_new(ptvcursor_tree(ptvc), sub_tvbuff, 0);
ptvcursor_t* sub_ptvc = ptvcursor_new(pinfo->pool, ptvcursor_tree(ptvc), sub_tvbuff, 0);
tlv->decode(sub_ptvc, pinfo);
@ -8165,7 +8165,7 @@ static int dissect_p45_header(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
static int dissect_p45_header_with_list(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
int offset = dissect_p45_header(tvb, pinfo, tree, data);
ptvcursor_t *ptvc = ptvcursor_new(tree, tvb, offset);
ptvcursor_t *ptvc = ptvcursor_new(pinfo->pool, tree, tvb, offset);
dissect_tlv_list(ptvc, pinfo, tvb_reported_length(tvb));
ptvcursor_free(ptvc);
@ -8189,7 +8189,7 @@ static int dissect_p45_header_with_error_and_list(tvbuff_t *tvb, packet_info *pi
proto_tree_add_item(tree, hf_nfapi_error_code, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
ptvc = ptvcursor_new(tree, tvb, offset);
ptvc = ptvcursor_new(pinfo->pool, tree, tvb, offset);
dissect_tlv_list(ptvc, pinfo, tvb_reported_length(tvb));
ptvcursor_free(ptvc);
@ -8213,7 +8213,7 @@ static int dissect_p45_header_with_p4_error_and_list(tvbuff_t *tvb, packet_info
proto_tree_add_item(tree, hf_nfapi_p4_error_code, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
ptvc = ptvcursor_new(tree, tvb, offset);
ptvc = ptvcursor_new(pinfo->pool, tree, tvb, offset);
dissect_tlv_list(ptvc, pinfo, tvb_reported_length(tvb));
ptvcursor_free(ptvc);
@ -8228,7 +8228,7 @@ static int dissect_p45_header_with_rat_type_list(tvbuff_t *tvb, packet_info *pin
proto_tree_add_item(tree, hf_nfapi_rat_type, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
ptvc = ptvcursor_new(tree, tvb, offset);
ptvc = ptvcursor_new(pinfo->pool, tree, tvb, offset);
dissect_tlv_list(ptvc, pinfo, tvb_reported_length(tvb));
ptvcursor_free(ptvc);
@ -8245,7 +8245,7 @@ static int dissect_p45_param_response_msg_id(tvbuff_t *tvb, packet_info *pinfo,
proto_tree_add_item(tree, hf_nfapi_num_tlv, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
ptvc = ptvcursor_new(tree, tvb, offset);
ptvc = ptvcursor_new(pinfo->pool, tree, tvb, offset);
dissect_tlv_list(ptvc, pinfo, tvb_reported_length(tvb));
ptvcursor_free(ptvc);
@ -8260,7 +8260,7 @@ static int dissect_p45_config_request_msg_id(tvbuff_t *tvb, packet_info *pinfo,
proto_tree_add_item(tree, hf_nfapi_num_tlv, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
ptvc = ptvcursor_new(tree, tvb, offset);
ptvc = ptvcursor_new(pinfo->pool, tree, tvb, offset);
dissect_tlv_list(ptvc, pinfo, tvb_reported_length(tvb));
ptvcursor_free(ptvc);
@ -8464,7 +8464,7 @@ static int dissect_nfapi_ul_p7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr
case NFAPI_RX_SR_INDICATION_MSG_ID:
case NFAPI_RX_CQI_INDICATION_MSG_ID:
{
ptvcursor_t *ptvc = ptvcursor_new(tree, tvb, offset);
ptvcursor_t *ptvc = ptvcursor_new(pinfo->pool, tree, tvb, offset);
ptvcursor_add(ptvc, hf_nfapi_sfn_sf, 2, ENC_BIG_ENDIAN);
dissect_tlv_list(ptvc, pinfo, msg_len);
ptvcursor_free(ptvc);
@ -8532,7 +8532,7 @@ static int dissect_nfapi_dl_p7(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr
case NFAPI_LBT_DL_CONFIG_REQUEST_MSG_ID:
case NFAPI_LBT_DL_INDICATION_MSG_ID:
{
ptvcursor_t *ptvc = ptvcursor_new(tree, tvb, offset);
ptvcursor_t *ptvc = ptvcursor_new(pinfo->pool, tree, tvb, offset);
ptvcursor_add(ptvc, hf_nfapi_sfn_sf, 2, ENC_BIG_ENDIAN);
dissect_tlv_list(ptvc, pinfo, msg_len);
ptvcursor_free(ptvc);

View File

@ -110,7 +110,7 @@ dissect_omapi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
ti = proto_tree_add_item(tree, proto_omapi, tvb, 0, -1, ENC_NA);
omapi_tree = proto_item_add_subtree(ti, ett_omapi);
cursor = ptvcursor_new(omapi_tree, tvb, 0);
cursor = ptvcursor_new(pinfo->pool, omapi_tree, tvb, 0);
if (tvb_reported_length_remaining(tvb, 0) < 24)
{

View File

@ -859,7 +859,7 @@ dissect_pgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
pgm_tree = proto_item_add_subtree(ti, ett_pgm);
cursor = ptvcursor_new(pgm_tree, tvb, 0);
cursor = ptvcursor_new(pinfo->pool, pgm_tree, tvb, 0);
hidden_item = proto_tree_add_item(pgm_tree, hf_pgm_port, tvb, 0, 2, ENC_BIG_ENDIAN);
proto_item_set_hidden(hidden_item);

View File

@ -407,7 +407,7 @@ add_ppi_field_header(tvbuff_t *tvb, proto_tree *tree, int *offset)
{
ptvcursor_t *csr;
csr = ptvcursor_new(tree, tvb, *offset);
csr = ptvcursor_new(wmem_packet_scope(), tree, tvb, *offset);
ptvcursor_add(csr, hf_ppi_field_type, 2, ENC_LITTLE_ENDIAN);
ptvcursor_add(csr, hf_ppi_field_len, 2, ENC_LITTLE_ENDIAN);
ptvcursor_free(csr);
@ -445,7 +445,7 @@ dissect_80211_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int of
else
phdr->fcs_len = 0;
csr = ptvcursor_new(ftree, tvb, offset);
csr = ptvcursor_new(pinfo->pool, ftree, tvb, offset);
tsft_raw = tvb_get_letoh64(tvb, offset);
if (tsft_raw != 0) {
@ -620,7 +620,7 @@ dissect_80211n_mac(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int
return;
}
csr = ptvcursor_new(ftree, tvb, offset);
csr = ptvcursor_new(pinfo->pool, ftree, tvb, offset);
flags = tvb_get_letohl(tvb, ptvcursor_current_offset(csr));
*n_mac_flags = flags;
@ -687,7 +687,7 @@ dissect_80211n_mac_phy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
FALSE, n_mac_flags, ampdu_id, phdr);
offset += PPI_80211N_MAC_PHY_OFF;
csr = ptvcursor_new(ftree, tvb, offset);
csr = ptvcursor_new(pinfo->pool, ftree, tvb, offset);
mcs = tvb_get_guint8(tvb, ptvcursor_current_offset(csr));
if (mcs != 255) {
@ -762,7 +762,7 @@ dissect_aggregation_extension(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree
return;
}
csr = ptvcursor_new(ftree, tvb, offset);
csr = ptvcursor_new(pinfo->pool, ftree, tvb, offset);
ptvcursor_add(csr, hf_aggregation_extension_interface_id, 4, ENC_LITTLE_ENDIAN); /* Last */
ptvcursor_free(csr);
@ -783,7 +783,7 @@ dissect_8023_extension(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
return;
}
csr = ptvcursor_new(ftree, tvb, offset);
csr = ptvcursor_new(pinfo->pool, ftree, tvb, offset);
ptvcursor_add_with_subtree(csr, hf_8023_extension_flags, 4, ENC_LITTLE_ENDIAN, ett_8023_extension_flags);
ptvcursor_add(csr, hf_8023_extension_flags_fcs_present, 4, ENC_LITTLE_ENDIAN);

View File

@ -110,7 +110,7 @@ static expert_field ei_roofnet_too_much_data = EI_INIT;
static guint16 dissect_roofnet_header(proto_tree *tree, tvbuff_t *tvb, guint *offset)
{
guint16 flags;
ptvcursor_t *cursor = ptvcursor_new(tree, tvb, *offset);
ptvcursor_t *cursor = ptvcursor_new(wmem_packet_scope(), tree, tvb, *offset);
ptvcursor_add(cursor, hf_roofnet_version, 1, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_roofnet_type, 1, ENC_BIG_ENDIAN);
@ -158,7 +158,7 @@ static void dissect_roofnet_link(proto_tree *tree, tvbuff_t *tvb, guint *offset,
proto_tree_add_ipv4(subtree, hf_roofnet_link_src, tvb, *offset, 4, addr_src);
*offset += 4;
cursor = ptvcursor_new(subtree, tvb, *offset);
cursor = ptvcursor_new(wmem_packet_scope(), subtree, tvb, *offset);
ptvcursor_add(cursor, hf_roofnet_link_forward, 4, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_roofnet_link_rev, 4, ENC_BIG_ENDIAN);

View File

@ -8087,7 +8087,7 @@ static int dissect_skinny_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
}
offset += 12;
cursor = ptvcursor_new(skinny_tree, tvb, offset);
cursor = ptvcursor_new(pinfo->pool, skinny_tree, tvb, offset);
if (opcode_entry && opcode_entry->handler) {
opcode_entry->handler(cursor, pinfo, skinny_conv);
}

View File

@ -811,7 +811,7 @@ static const unit_name_string mb_unit = {"MB", NULL};
static int
dissect_loginserv_packet(struct tibia_convo *convo, tvbuff_t *tvb, int offset, int len, packet_info *pinfo, proto_tree *tree, gboolean first_fragment )
{
ptvcursor_t *ptvc = ptvcursor_new(tree, tvb, offset);
ptvcursor_t *ptvc = ptvcursor_new(pinfo->pool, tree, tvb, offset);
col_append_str(pinfo->cinfo, COL_INFO, first_fragment ? " commands:" : ",");
len += offset;
@ -966,7 +966,7 @@ dissect_coord(ptvcursor_t *ptvc, gboolean with_stackpos)
static int
dissect_gameserv_packet(struct tibia_convo *convo, tvbuff_t *tvb, int offset, int len, packet_info *pinfo, proto_tree *tree, gboolean first_fragment)
{
ptvcursor_t *ptvc = ptvcursor_new(tree, tvb, offset);
ptvcursor_t *ptvc = ptvcursor_new(pinfo->pool, tree, tvb, offset);
col_append_str(pinfo->cinfo, COL_INFO, first_fragment ? " commands:" : ",");
len += offset;
@ -1169,7 +1169,7 @@ dissect_gameserv_packet(struct tibia_convo *convo, tvbuff_t *tvb, int offset, in
static int
dissect_client_packet(struct tibia_convo *convo, tvbuff_t *tvb, int offset, int len, packet_info *pinfo, proto_tree *tree, gboolean first_fragment)
{
ptvcursor_t *ptvc = ptvcursor_new(tree, tvb, offset);
ptvcursor_t *ptvc = ptvcursor_new(pinfo->pool, tree, tvb, offset);
col_append_str(pinfo->cinfo, COL_INFO, first_fragment ? " commands:" : ",");
len += offset;

View File

@ -51,7 +51,7 @@ static int dissect_vicp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
ti = proto_tree_add_item(tree, proto_vicp, tvb, 0, -1, ENC_NA);
vicp_tree = proto_item_add_subtree(ti, ett_vicp);
cursor = ptvcursor_new(vicp_tree, tvb, 0);
cursor = ptvcursor_new(pinfo->pool, vicp_tree, tvb, 0);
ptvcursor_add(cursor, hf_vicp_operation, 1, ENC_BIG_ENDIAN);
ptvcursor_add(cursor, hf_vicp_version, 1, ENC_BIG_ENDIAN);

View File

@ -4659,7 +4659,7 @@ add_body_fields(guint32 opcode,
gint32 offset_packet_end)
{
gint32 len = 0;
ptvcursor_t* ptv = ptvcursor_new(tree, tvb, offset);
ptvcursor_t* ptv = ptvcursor_new(wmem_packet_scope(), tree, tvb, offset);
switch (opcode) {
case SMSG_AUTH_CHALLENGE:
ptvcursor_add(ptv, hf_woww_challenge_seed, 4, ENC_LITTLE_ENDIAN);

View File

@ -62,6 +62,7 @@ typedef struct __subtree_lvl {
} subtree_lvl;
struct ptvcursor {
wmem_allocator_t *scope;
subtree_lvl *pushed_tree;
guint8 pushed_tree_index;
guint8 pushed_tree_max;
@ -1119,7 +1120,7 @@ ptvcursor_new_subtree_levels(ptvcursor_t *ptvc)
DISSECTOR_ASSERT(ptvc->pushed_tree_max <= SUBTREE_MAX_LEVELS-SUBTREE_ONCE_ALLOCATION_NUMBER);
ptvc->pushed_tree_max += SUBTREE_ONCE_ALLOCATION_NUMBER;
pushed_tree = (subtree_lvl *)wmem_realloc(wmem_packet_scope(), (void *)ptvc->pushed_tree, sizeof(subtree_lvl) * ptvc->pushed_tree_max);
pushed_tree = (subtree_lvl *)wmem_realloc(ptvc->scope, (void *)ptvc->pushed_tree, sizeof(subtree_lvl) * ptvc->pushed_tree_max);
DISSECTOR_ASSERT(pushed_tree != NULL);
ptvc->pushed_tree = pushed_tree;
}
@ -1136,11 +1137,12 @@ ptvcursor_free_subtree_levels(ptvcursor_t *ptvc)
/* Allocates an initializes a ptvcursor_t with 3 variables:
* proto_tree, tvbuff, and offset. */
ptvcursor_t *
ptvcursor_new(proto_tree *tree, tvbuff_t *tvb, gint offset)
ptvcursor_new(wmem_allocator_t *scope, proto_tree *tree, tvbuff_t *tvb, gint offset)
{
ptvcursor_t *ptvc;
ptvc = wmem_new(wmem_packet_scope(), ptvcursor_t);
ptvc = wmem_new(scope, ptvcursor_t);
ptvc->scope = scope;
ptvc->tree = tree;
ptvc->tvb = tvb;
ptvc->offset = offset;

View File

@ -25,7 +25,7 @@ typedef struct ptvcursor ptvcursor_t;
* proto_tree, tvbuff, and offset. */
WS_DLL_PUBLIC
ptvcursor_t*
ptvcursor_new(proto_tree* tree, tvbuff_t* tvb, gint offset);
ptvcursor_new(wmem_allocator_t *scope, proto_tree* tree, tvbuff_t* tvb, gint offset);
/* Gets data from tvbuff, adds it to proto_tree, increments offset,
* and returns proto_item* */