diff options
author | Evan Huus <eapache@gmail.com> | 2023-12-31 10:42:11 -0500 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2023-12-31 10:42:11 -0500 |
commit | c08e6e56fd1313cde7e90190a0dfe98989936b60 (patch) | |
tree | ac3f03a5269a03b3249bb9879751e70683fae61f | |
parent | 4a454d8d626ade8804d2d492c796939d82b484b6 (diff) |
Remove packet scope usage from a few dissectors
Mostly just passing pinfo around a little bit more, but in rf4ce-nwk we
weren't doing anything with the allocated value anyway, so just use the
regular proto_tree_add_item.
-rw-r--r-- | epan/dissectors/packet-dbus.c | 8 | ||||
-rw-r--r-- | epan/dissectors/packet-rf4ce-nwk.c | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-srt.c | 10 | ||||
-rw-r--r-- | epan/dissectors/packet-tftp.c | 14 |
4 files changed, 17 insertions, 18 deletions
diff --git a/epan/dissectors/packet-dbus.c b/epan/dissectors/packet-dbus.c index aa40061a2e..94c6a0862f 100644 --- a/epan/dissectors/packet-dbus.c +++ b/epan/dissectors/packet-dbus.c @@ -460,11 +460,11 @@ skip_single_complete_type(const char *signature) { } static gboolean -is_dbus_signature_valid(const char *signature) { +is_dbus_signature_valid(const char *signature, dbus_packet_t *packet) { char sig_code; size_t length = 0; char prev_sig_code = '\0'; - wmem_stack_t *expected_chars = wmem_stack_new(wmem_packet_scope()); + wmem_stack_t *expected_chars = wmem_stack_new(packet->pinfo->pool); while ((sig_code = *signature++) != '\0') { if (++length >= DBUS_MAX_SIGNATURE_LENGTH) { @@ -726,7 +726,7 @@ reader_next(dbus_type_reader_t *reader, int hf, int ett, dbus_val_t *value) { } case SIG_CODE_SIGNATURE: { const char *val = add_dbus_string(packet, hf != -1 ? hf : hf_dbus_type_signature, 1); - if (!val || !is_dbus_signature_valid(val)) { + if (!val || !is_dbus_signature_valid(val, packet)) { add_expert(packet, &ei_dbus_type_signature_invalid); err = 1; } @@ -792,7 +792,7 @@ reader_next(dbus_type_reader_t *reader, int hf, int ett, dbus_val_t *value) { SUBTREE_UNDEFINED_LENGTH, ENC_NA, ett != -1 ? ett : ett_dbus_type_variant); const char *variant_signature = add_dbus_string(packet, hf_dbus_type_variant_signature, 1); value->string = variant_signature; - if (variant_signature && is_dbus_signature_valid(variant_signature)) { + if (variant_signature && is_dbus_signature_valid(variant_signature, packet)) { if (variant_signature[0] != '\0') { dbus_type_reader_t *child = wmem_new(packet->pinfo->pool, dbus_type_reader_t); *child = (dbus_type_reader_t){ diff --git a/epan/dissectors/packet-rf4ce-nwk.c b/epan/dissectors/packet-rf4ce-nwk.c index cc156e6a5a..3fc85ebe5c 100644 --- a/epan/dissectors/packet-rf4ce-nwk.c +++ b/epan/dissectors/packet-rf4ce-nwk.c @@ -921,13 +921,12 @@ static void dissect_rf4ce_nwk_common_node_capabilities(tvbuff_t *tvb, proto_tree static void dissect_rf4ce_nwk_common_vendor_info(tvbuff_t *tvb, proto_tree *tree, gint *offset) { - const guint8 *prodname; proto_tree *vendor_info_tree = proto_tree_add_subtree(tree, tvb, *offset, tvb_captured_length(tvb) - *offset, ett_rf4ce_nwk_vendor_info, NULL, "Vendor Information Fields"); proto_tree_add_item(vendor_info_tree, hf_rf4ce_nwk_disc_req_vendor_id, tvb, *offset, 2, ENC_LITTLE_ENDIAN); *offset += 2; - proto_tree_add_item_ret_string(vendor_info_tree, hf_rf4ce_nwk_vendor_string, tvb, *offset, RF4CE_NWK_VENDOR_STRING_MAX_LENGTH, ENC_UTF_8, wmem_packet_scope(), &prodname); + proto_tree_add_item(vendor_info_tree, hf_rf4ce_nwk_vendor_string, tvb, *offset, RF4CE_NWK_VENDOR_STRING_MAX_LENGTH, ENC_UTF_8); *offset += RF4CE_NWK_VENDOR_STRING_MAX_LENGTH; } diff --git a/epan/dissectors/packet-srt.c b/epan/dissectors/packet-srt.c index 868a6b364c..076c7ea93c 100644 --- a/epan/dissectors/packet-srt.c +++ b/epan/dissectors/packet-srt.c @@ -576,9 +576,9 @@ static void dissect_srt_hs_ext_field(proto_tree* tree, * * and so on, with null padding (not null termination). */ -static void format_text_reorder_32(proto_tree* tree, tvbuff_t* tvb, int hfinfo, int baseoff, int blocklen) +static void format_text_reorder_32(proto_tree* tree, tvbuff_t* tvb, packet_info *pinfo, int hfinfo, int baseoff, int blocklen) { - wmem_strbuf_t *sid = wmem_strbuf_create(wmem_packet_scope()); + wmem_strbuf_t *sid = wmem_strbuf_create(pinfo->pool); for (int ii = 0; ii < blocklen; ii += 4) { // @@ -767,7 +767,7 @@ dissect_srt_control_packet(tvbuff_t *tvb, packet_info* pinfo, proto_tree_add_item(tree, hf_srt_handshake_cookie, tvb, 44, 4, ENC_BIG_ENDIAN); - srt_format_ip_address(ipbuf, sizeof ipbuf, (const gchar *)tvb_memdup(wmem_packet_scope(), tvb, 48, 16)); + srt_format_ip_address(ipbuf, sizeof ipbuf, (const gchar *)tvb_memdup(pinfo->pool, tvb, 48, 16)); proto_tree_add_string(tree, hf_srt_handshake_peerip, tvb, 48, 16, ipbuf); @@ -815,11 +815,11 @@ dissect_srt_control_packet(tvbuff_t *tvb, packet_info* pinfo, break; case SRT_CMD_SID: - format_text_reorder_32(tree, tvb, hf_srt_srths_sid, begin, 4 * blocklen); + format_text_reorder_32(tree, tvb, pinfo, hf_srt_srths_sid, begin, 4 * blocklen); break; case SRT_CMD_CONGESTCTRL: - format_text_reorder_32(tree, tvb, hf_srt_srths_congestcontrol, begin, 4 * blocklen); + format_text_reorder_32(tree, tvb, pinfo, hf_srt_srths_congestcontrol, begin, 4 * blocklen); break; default: diff --git a/epan/dissectors/packet-tftp.c b/epan/dissectors/packet-tftp.c index fa57ceb8e8..de78d38975 100644 --- a/epan/dissectors/packet-tftp.c +++ b/epan/dissectors/packet-tftp.c @@ -759,7 +759,7 @@ tftp_info_for_conversation(conversation_t *conversation) } static gboolean -is_valid_request_body(tvbuff_t *tvb) +is_valid_request_body(tvbuff_t *tvb, packet_info *pinfo) { gint offset = 2; guint zeros_counter = 0; @@ -777,7 +777,7 @@ is_valid_request_body(tvbuff_t *tvb) offset += tvb_strsize(tvb, offset); guint len = tvb_strsize(tvb, offset); - const gchar* mode = tvb_format_stringzpad(wmem_packet_scope(), tvb, offset, len); + const gchar* mode = tvb_format_stringzpad(pinfo->pool, tvb, offset, len); const gchar* modes[] = {"netscii", "octet", "mail"}; for(guint i = 0; i < array_length(modes); ++i) { @@ -788,14 +788,14 @@ is_valid_request_body(tvbuff_t *tvb) } static gboolean -is_valid_request(tvbuff_t *tvb) +is_valid_request(tvbuff_t *tvb, packet_info *pinfo) { if (tvb_captured_length(tvb) < MIN_HDR_LEN) return FALSE; guint16 opcode = tvb_get_ntohs(tvb, 0); if ((opcode != TFTP_RRQ) && (opcode != TFTP_WRQ)) return FALSE; - return is_valid_request_body(tvb); + return is_valid_request_body(tvb, pinfo); } static conversation_t* create_tftp_conversation(packet_info *pinfo) @@ -820,7 +820,7 @@ static conversation_t* create_tftp_conversation(packet_info *pinfo) static gboolean dissect_tftp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - if (is_valid_request_body(tvb)) { + if (is_valid_request_body(tvb, pinfo)) { conversation_t* conversation = create_tftp_conversation(pinfo); dissect_tftp_message(tftp_info_for_conversation(conversation), tvb, pinfo, tree); return TRUE; @@ -850,7 +850,7 @@ dissect_embeddedtftp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v case TFTP_RRQ: case TFTP_WRQ: /* These 2 opcodes have a NULL-terminated source file name after opcode. Verify */ - if (!is_valid_request_body(tvb)) + if (!is_valid_request_body(tvb, pinfo)) return FALSE; /* Intentionally dropping through here... */ case TFTP_DATA: @@ -910,7 +910,7 @@ dissect_tftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ */ if ((value_is_in_range(global_tftp_port_range, pinfo->destport) || (pinfo->match_uint == pinfo->destport)) && - is_valid_request(tvb)) + is_valid_request(tvb, pinfo)) { conversation = create_tftp_conversation(pinfo); } |