From 2ab415579491e4bc66ea58627bda504cae833b9e Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Sun, 26 Jun 2016 10:52:37 -0400 Subject: tvb_get_string_enc + proto_tree_add_item = proto_tree_add_item_ret_string Also some other tricks to remove unnecessary tvb_get_string_enc calls. Change-Id: I2f40d9175b6c0bb0b1364b4089bfaa287edf0914 Reviewed-on: https://code.wireshark.org/review/16158 Petri-Dish: Pascal Quantin Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann Reviewed-by: Pascal Quantin --- .../asn1/ansi_map/packet-ansi_map-template.c | 16 +- epan/dissectors/asn1/c1222/packet-c1222-template.c | 10 +- epan/dissectors/asn1/gsm_map/gsm_map.cnf | 6 +- epan/dissectors/file-pcapng.c | 51 ++--- epan/dissectors/packet-aastra-aasp.c | 11 +- epan/dissectors/packet-adb_cs.c | 6 +- epan/dissectors/packet-alljoyn.c | 109 +++++---- epan/dissectors/packet-amqp.c | 246 ++++++++++----------- epan/dissectors/packet-ansi_map.c | 22 +- epan/dissectors/packet-ar_drone.c | 7 +- epan/dissectors/packet-artnet.c | 35 ++- epan/dissectors/packet-bfd.c | 23 +- epan/dissectors/packet-bitcoin.c | 9 +- epan/dissectors/packet-bootp.c | 7 +- epan/dissectors/packet-btavrcp.c | 5 +- epan/dissectors/packet-bthcrp.c | 5 +- epan/dissectors/packet-btsdp.c | 100 ++++----- epan/dissectors/packet-c1222.c | 16 +- epan/dissectors/packet-catapult-dct2000.c | 12 +- epan/dissectors/packet-cell_broadcast.c | 8 +- epan/dissectors/packet-cmpp.c | 7 +- epan/dissectors/packet-coap.c | 6 +- epan/dissectors/packet-collectd.c | 29 ++- epan/dissectors/packet-dcerpc-epm.c | 18 +- epan/dissectors/packet-dcerpc-fileexp.c | 3 +- epan/dissectors/packet-dcerpc-fldb.c | 55 ++--- epan/dissectors/packet-dcerpc-rpriv.c | 10 +- epan/dissectors/packet-dcerpc-rs_acct.c | 12 +- epan/dissectors/packet-dcerpc-rs_misc.c | 5 +- epan/dissectors/packet-dcerpc-rs_pgo.c | 36 ++- epan/dissectors/packet-dcerpc-spoolss.c | 14 +- epan/dissectors/packet-dcp-etsi.c | 10 +- epan/dissectors/packet-dhcp-failover.c | 21 +- epan/dissectors/packet-diameter_3gpp.c | 16 +- epan/dissectors/packet-dis.c | 10 +- epan/dissectors/packet-dmp.c | 5 +- epan/dissectors/packet-dnp.c | 9 +- epan/dissectors/packet-dns.c | 5 +- epan/dissectors/packet-dtn.c | 7 +- epan/dissectors/packet-dvbci.c | 29 +-- epan/dissectors/packet-edonkey.c | 7 +- epan/dissectors/packet-epmd.c | 20 +- epan/dissectors/packet-erldp.c | 13 +- epan/dissectors/packet-exported_pdu.c | 18 +- epan/dissectors/packet-extreme.c | 14 +- epan/dissectors/packet-foundry.c | 8 +- epan/dissectors/packet-gearman.c | 5 +- epan/dissectors/packet-gsm_a_dtap.c | 4 +- epan/dissectors/packet-gsm_map.c | 6 +- epan/dissectors/packet-hpfeeds.c | 7 +- epan/dissectors/packet-icep.c | 15 +- epan/dissectors/packet-ieee80211-prism.c | 5 +- epan/dissectors/packet-ieee80211.c | 41 ++-- epan/dissectors/packet-imf.c | 25 +-- epan/dissectors/packet-irc.c | 66 +++--- epan/dissectors/packet-isakmp.c | 54 ++--- epan/dissectors/packet-m2tp.c | 5 +- epan/dissectors/packet-mikey.c | 14 +- epan/dissectors/packet-mip6.c | 24 +- epan/dissectors/packet-ms-mms.c | 34 ++- epan/dissectors/packet-mswsp.c | 31 ++- epan/dissectors/packet-mysql.c | 11 +- epan/dissectors/packet-netflow.c | 12 +- epan/dissectors/packet-netlink-route.c | 10 +- epan/dissectors/packet-ntlmssp.c | 17 +- epan/dissectors/packet-obex.c | 16 +- epan/dissectors/packet-opsi.c | 10 +- epan/dissectors/packet-pana.c | 8 +- epan/dissectors/packet-pflog.c | 10 +- epan/dissectors/packet-ppcap.c | 5 +- epan/dissectors/packet-pppoe.c | 10 +- epan/dissectors/packet-ptpip.c | 13 +- epan/dissectors/packet-quake2.c | 6 +- epan/dissectors/packet-quic.c | 26 ++- epan/dissectors/packet-radius.c | 5 +- epan/dissectors/packet-rpcap.c | 13 +- epan/dissectors/packet-rsvp.c | 16 +- epan/dissectors/packet-rtcp.c | 4 +- epan/dissectors/packet-rtpproxy.c | 12 +- epan/dissectors/packet-rtps.c | 25 +-- epan/dissectors/packet-s7comm.c | 27 +-- epan/dissectors/packet-sametime.c | 3 +- epan/dissectors/packet-sbus.c | 8 +- epan/dissectors/packet-sdp.c | 124 +++++------ epan/dissectors/packet-sip.c | 5 +- epan/dissectors/packet-smb-pipe.c | 10 +- epan/dissectors/packet-smb.c | 30 ++- epan/dissectors/packet-stun.c | 46 ++-- epan/dissectors/packet-tcpros.c | 10 +- epan/dissectors/packet-tftp.c | 25 +-- epan/dissectors/packet-tnef.c | 7 +- epan/dissectors/packet-ubertooth.c | 16 +- epan/dissectors/packet-uma.c | 5 +- epan/dissectors/packet-v5ua.c | 24 +- epan/dissectors/packet-vnc.c | 15 +- 95 files changed, 900 insertions(+), 1111 deletions(-) (limited to 'epan') diff --git a/epan/dissectors/asn1/ansi_map/packet-ansi_map-template.c b/epan/dissectors/asn1/ansi_map/packet-ansi_map-template.c index 4573fd4eb8..9249203dd9 100644 --- a/epan/dissectors/asn1/ansi_map/packet-ansi_map-template.c +++ b/epan/dissectors/asn1/ansi_map/packet-ansi_map-template.c @@ -699,14 +699,18 @@ dissect_ansi_map_digits_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree proto_item_append_text(actx->created_item, " - %s", digit_str); break; case 2: + { + const guint8* digits; /* IA5 Coding */ octet_len = tvb_get_guint8(tvb,offset); proto_tree_add_item(subtree, hf_ansi_map_nr_digits, tvb, offset, 1, ENC_BIG_ENDIAN); if(octet_len == 0) return; offset++; - proto_tree_add_item(subtree, hf_ansi_map_ia5_digits, tvb, offset, -1, ENC_ASCII|ENC_NA); - proto_item_append_text(actx->created_item, " - %s", tvb_get_string_enc(wmem_packet_scope(),tvb,offset,tvb_reported_length_remaining(tvb,offset),ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(subtree, hf_ansi_map_ia5_digits, tvb, offset, tvb_reported_length_remaining(tvb,offset), + ENC_ASCII|ENC_NA, wmem_packet_scope(), &digits); + proto_item_append_text(actx->created_item, " - %s", digits); + } break; case 3: /* Octet string */ @@ -737,9 +741,13 @@ dissect_ansi_map_digits_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree proto_item_append_text(actx->created_item, " - %s", digit_str); break; case 2: + { + const guint8* digits; /* IA5 Coding */ - proto_tree_add_item(subtree, hf_ansi_map_ia5_digits, tvb, offset, -1, ENC_ASCII|ENC_NA); - proto_item_append_text(actx->created_item, " - %s", tvb_get_string_enc(wmem_packet_scope(),tvb,offset,tvb_reported_length_remaining(tvb,offset),ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(subtree, hf_ansi_map_ia5_digits, tvb, offset, tvb_reported_length_remaining(tvb,offset), + ENC_ASCII|ENC_NA, wmem_packet_scope(), &digits); + proto_item_append_text(actx->created_item, " - %s", digits); + } break; case 3: /* Octet string */ diff --git a/epan/dissectors/asn1/c1222/packet-c1222-template.c b/epan/dissectors/asn1/c1222/packet-c1222-template.c index c10244893e..c01a342ea0 100644 --- a/epan/dissectors/asn1/c1222/packet-c1222-template.c +++ b/epan/dissectors/asn1/c1222/packet-c1222-template.c @@ -374,8 +374,8 @@ static void parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cmd, guint32 *length, int *offset) { guint16 user_id = 0; - guint8 *user_name = NULL; - guint8 *password = NULL; + const guint8 *user_name = NULL; + const guint8 *password = NULL; guint8 auth_len = 0; gchar *auth_req = NULL; guint16 table = 0; @@ -408,8 +408,7 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm user_id = tvb_get_ntohs(tvb, *offset); proto_tree_add_uint(tree, hf_c1222_logon_id, tvb, *offset, 2, user_id); *offset += 2; - user_name = tvb_get_string_enc(wmem_packet_scope(),tvb, *offset, 10, ENC_ASCII); - proto_tree_add_string(tree, hf_c1222_logon_user, tvb, *offset, 10, user_name); + proto_tree_add_item_ret_string(tree, hf_c1222_logon_user, tvb, *offset, 10, ENC_ASCII|ENC_NA, wmem_packet_scope(), &user_name); *offset += 10; *length -= 12; proto_item_set_text(tree, "C12.22 EPSEM: %s (id %d, user \"%s\")", @@ -420,8 +419,7 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm break; case C1222_CMD_SECURITY: if (*length >= 20) { - password = tvb_get_string_enc(wmem_packet_scope(),tvb, *offset, 20, ENC_ASCII); - proto_tree_add_string(tree, hf_c1222_security_password, tvb, *offset, 20, password); + proto_tree_add_item_ret_string(tree, hf_c1222_security_password, tvb, *offset, 20, ENC_ASCII|ENC_NA, wmem_packet_scope(), &password); *offset += 20; *length -= 20; if (*length >= 2) { diff --git a/epan/dissectors/asn1/gsm_map/gsm_map.cnf b/epan/dissectors/asn1/gsm_map/gsm_map.cnf index 1e66907880..e7216a80ee 100644 --- a/epan/dissectors/asn1/gsm_map/gsm_map.cnf +++ b/epan/dissectors/asn1/gsm_map/gsm_map.cnf @@ -556,15 +556,15 @@ actx->pinfo->p2p_dir = P2P_DIR_RECV; switch(sms_encoding){ case SMS_ENCODING_7BIT: case SMS_ENCODING_7BIT_LANG: - proto_tree_add_string(subtree, hf_gsm_map_ussd_string, parameter_tvb, 0, length, tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, 0, length, ENC_3GPP_TS_23_038_7BITS|ENC_NA)); + proto_tree_add_item(subtree, hf_gsm_map_ussd_string, parameter_tvb, 0, length, ENC_3GPP_TS_23_038_7BITS|ENC_NA); break; case SMS_ENCODING_8BIT: /* XXX - ASCII, or some extended ASCII? */ - proto_tree_add_string(subtree, hf_gsm_map_ussd_string, parameter_tvb, 0, length, tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, 0, length, ENC_ASCII|ENC_NA)); + proto_tree_add_item(subtree, hf_gsm_map_ussd_string, parameter_tvb, 0, length, ENC_ASCII|ENC_NA); break; case SMS_ENCODING_UCS2: case SMS_ENCODING_UCS2_LANG: - proto_tree_add_string(subtree, hf_gsm_map_ussd_string, parameter_tvb, 0, length, tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, 0, length, ENC_UCS_2|ENC_BIG_ENDIAN)); + proto_tree_add_item(subtree, hf_gsm_map_ussd_string, parameter_tvb, 0, length, ENC_UCS_2|ENC_BIG_ENDIAN); break; default: break; diff --git a/epan/dissectors/file-pcapng.c b/epan/dissectors/file-pcapng.c index 098b076662..8e650a8aeb 100644 --- a/epan/dissectors/file-pcapng.c +++ b/epan/dissectors/file-pcapng.c @@ -337,17 +337,17 @@ void proto_reg_handoff_pcapng(void); static gint dissect_options(proto_tree *tree, packet_info *pinfo, guint32 block_type, tvbuff_t *tvb, guint encoding, void *user_data) { - proto_tree *options_tree; - proto_item *options_item; - proto_tree *option_tree; - proto_item *option_item; - proto_item *p_item; - gint offset = 0; - guint16 option_code; - gint option_length; - gint hfj_pcapng_option_code; - const gchar *str = NULL; - address addr; + proto_tree *options_tree; + proto_item *options_item; + proto_tree *option_tree; + proto_item *option_item; + proto_item *p_item; + gint offset = 0; + guint16 option_code; + gint option_length; + gint hfj_pcapng_option_code; + const guint8 *str = NULL; + address addr; address addr_mask; const value_string *vals = NULL; union value { @@ -411,25 +411,21 @@ static gint dissect_options(proto_tree *tree, packet_info *pinfo, if (option_code == 0 && option_length == 0) { break; } else if (option_code == 1) { - proto_tree_add_item(option_tree, hf_pcapng_option_data_comment, tvb, offset, option_length, ENC_NA | ENC_UTF_8); - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, option_length, ENC_UTF_8); + proto_tree_add_item_ret_string(option_tree, hf_pcapng_option_data_comment, tvb, offset, option_length, ENC_NA | ENC_UTF_8, wmem_packet_scope(), &str); offset += option_length; } else switch (block_type) { case BLOCK_SECTION_HEADER: switch (option_code) { case 0x0002: - proto_tree_add_item(option_tree, hf_pcapng_option_data_section_header_hardware, tvb, offset, option_length, ENC_NA | ENC_UTF_8); - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, option_length, ENC_UTF_8); + proto_tree_add_item_ret_string(option_tree, hf_pcapng_option_data_section_header_hardware, tvb, offset, option_length, ENC_NA | ENC_UTF_8, wmem_packet_scope(), &str); offset += option_length; break; case 0x0003: - proto_tree_add_item(option_tree, hf_pcapng_option_data_section_header_os, tvb, offset, option_length, ENC_NA | ENC_UTF_8); - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, option_length, ENC_UTF_8); + proto_tree_add_item_ret_string(option_tree, hf_pcapng_option_data_section_header_os, tvb, offset, option_length, ENC_NA | ENC_UTF_8, wmem_packet_scope(), &str); offset += option_length; break; case 0x0004: - proto_tree_add_item(option_tree, hf_pcapng_option_data_section_header_user_application, tvb, offset, option_length, ENC_NA | ENC_UTF_8); - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, option_length, ENC_UTF_8); + proto_tree_add_item_ret_string(option_tree, hf_pcapng_option_data_section_header_user_application, tvb, offset, option_length, ENC_NA | ENC_UTF_8, wmem_packet_scope(), &str); offset += option_length; break; default: @@ -442,16 +438,12 @@ static gint dissect_options(proto_tree *tree, packet_info *pinfo, switch (option_code) { case 0x0002: - proto_tree_add_item(option_tree, hf_pcapng_option_data_interface_description_name, tvb, offset, option_length, ENC_NA | ENC_UTF_8); - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, option_length, ENC_UTF_8); + proto_tree_add_item_ret_string(option_tree, hf_pcapng_option_data_interface_description_name, tvb, offset, option_length, ENC_NA | ENC_UTF_8, wmem_packet_scope(), &str); offset += option_length; - break; case 0x0003: - proto_tree_add_item(option_tree, hf_pcapng_option_data_interface_description_description, tvb, offset, option_length, ENC_NA | ENC_UTF_8); - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, option_length, ENC_UTF_8); + proto_tree_add_item_ret_string(option_tree, hf_pcapng_option_data_interface_description_description, tvb, offset, option_length, ENC_NA | ENC_UTF_8, wmem_packet_scope(), &str); offset += option_length; - break; case 0x0004: if (option_length != 8) { @@ -576,14 +568,12 @@ static gint dissect_options(proto_tree *tree, packet_info *pinfo, break; case 0x000B: - proto_tree_add_item(option_tree, hf_pcapng_option_data_interface_filter, tvb, offset, option_length, ENC_NA | ENC_UTF_8); - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, option_length, ENC_UTF_8); + proto_tree_add_item_ret_string(option_tree, hf_pcapng_option_data_interface_filter, tvb, offset, option_length, ENC_NA | ENC_UTF_8, wmem_packet_scope(), &str); offset += option_length; break; case 0x000C: - proto_tree_add_item(option_tree, hf_pcapng_option_data_interface_os, tvb, offset, option_length, ENC_NA | ENC_UTF_8); - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, option_length, ENC_UTF_8); + proto_tree_add_item_ret_string(option_tree, hf_pcapng_option_data_interface_os, tvb, offset, option_length, ENC_NA | ENC_UTF_8, wmem_packet_scope(), &str); offset += option_length; break; @@ -664,8 +654,7 @@ static gint dissect_options(proto_tree *tree, packet_info *pinfo, case BLOCK_NAME_RESOLUTION: switch (option_code) { case 0x0002: - proto_tree_add_item(option_tree, hf_pcapng_option_data_dns_name, tvb, offset, option_length, ENC_NA | ENC_UTF_8); - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, option_length, ENC_UTF_8); + proto_tree_add_item_ret_string(option_tree, hf_pcapng_option_data_dns_name, tvb, offset, option_length, ENC_NA | ENC_UTF_8, wmem_packet_scope(), &str); offset += option_length; break; diff --git a/epan/dissectors/packet-aastra-aasp.c b/epan/dissectors/packet-aastra-aasp.c index 0ec5c70dff..cf71394984 100644 --- a/epan/dissectors/packet-aastra-aasp.c +++ b/epan/dissectors/packet-aastra-aasp.c @@ -138,7 +138,7 @@ dissect_a_binary_command(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree { proto_item *ti; proto_tree *subtree; - guint8* pstr; + const guint8* pstr; guint i, len; /* create command subtree */ @@ -277,8 +277,7 @@ dissect_a_binary_command(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree len = tvb_get_guint8(tvb, i+1); ti = proto_tree_add_item(subtree, hf_a_item, tvb, i, len+2, ENC_NA); infotree = proto_item_add_subtree(ti, ett_a_item); - proto_tree_add_item(infotree, hf_a_weekday, tvb, i+2, len, ENC_ASCII|ENC_NA); - pstr = tvb_get_string_enc(wmem_packet_scope(), tvb, i+2, len, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(infotree, hf_a_weekday, tvb, i+2, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &pstr); if(pstr) proto_item_append_text(ti, ", Weekday: '%s'", pstr); @@ -290,8 +289,7 @@ dissect_a_binary_command(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree len = tvb_get_guint8(tvb, i+1); ti = proto_tree_add_item(subtree, hf_a_item, tvb, i, len+2, ENC_NA); infotree = proto_item_add_subtree(ti, ett_a_item); - proto_tree_add_item(infotree, hf_a_month_name, tvb, i+2, len, ENC_ASCII|ENC_NA); - pstr = tvb_get_string_enc(wmem_packet_scope(), tvb, i+2, len, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(infotree, hf_a_month_name, tvb, i+2, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &pstr); if(pstr) proto_item_append_text(ti, ", Month name: '%s'", pstr); i += len +2; @@ -302,8 +300,7 @@ dissect_a_binary_command(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree len = tvb_get_guint8(tvb, i+1); ti = proto_tree_add_item(subtree, hf_a_item, tvb, i, len+2, ENC_NA); infotree = proto_item_add_subtree(ti, ett_a_item); - proto_tree_add_item(infotree, hf_a_weekofyear_prefix, tvb, i+2, len, ENC_ASCII|ENC_NA); - pstr = tvb_get_string_enc(wmem_packet_scope(), tvb, i+2, len, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(infotree, hf_a_weekofyear_prefix, tvb, i+2, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &pstr); if(pstr) proto_item_append_text(ti, ", Week of the year prefix: '%s'", pstr); i += len +2; diff --git a/epan/dissectors/packet-adb_cs.c b/epan/dissectors/packet-adb_cs.c index 5bac91b1b7..910906264f 100644 --- a/epan/dissectors/packet-adb_cs.c +++ b/epan/dissectors/packet-adb_cs.c @@ -320,12 +320,14 @@ dissect_adb_cs(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _ if (tvb_reported_length_remaining(tvb, offset) <= 0) return offset; if (status == STATUS_FAIL) { - sub_item = proto_tree_add_item(main_tree, hf_fail_reason, tvb, offset, -1, ENC_NA | ENC_ASCII); + const guint8* str; + sub_item = proto_tree_add_item_ret_string(main_tree, hf_fail_reason, tvb, offset, + tvb_reported_length_remaining(tvb, offset), ENC_NA | ENC_ASCII, wmem_packet_scope(), &str); if (length < tvb_reported_length_remaining(tvb, offset)) { expert_add_info(pinfo, sub_item, &ei_incomplete_message); } - col_append_fstr(pinfo->cinfo, COL_INFO, " Fail=<%s>", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII)); + col_append_fstr(pinfo->cinfo, COL_INFO, " Fail=<%s>", str); return tvb_captured_length(tvb); } diff --git a/epan/dissectors/packet-alljoyn.c b/epan/dissectors/packet-alljoyn.c index f890ab011d..21e76057e9 100644 --- a/epan/dissectors/packet-alljoyn.c +++ b/epan/dissectors/packet-alljoyn.c @@ -712,7 +712,7 @@ pad_according_to_type(gint offset, gint field_starting_offset, gint max_offset, */ static void append_struct_signature(proto_item *item, - guint8 *signature, + const guint8 *signature, gint signature_max_length, const guint8 type_stop) { @@ -752,7 +752,7 @@ append_struct_signature(proto_item *item, * @param signature_length is a pointer to the length of the signature. */ static void -advance_to_end_of_signature(guint8 **signature, +advance_to_end_of_signature(const guint8 **signature, guint8 *signature_length) { gboolean done = FALSE; @@ -859,18 +859,18 @@ static void add_padding_item(gint padding_start, gint padding_end, tvbuff_t *tvb * parameters come in. */ static gint -parse_arg(tvbuff_t *tvb, - packet_info *pinfo, - proto_item *header_item, - guint encoding, - gint offset, - proto_tree *field_tree, - gboolean is_reply_to, - guint8 type_id, - guint8 field_code, - guint8 **signature, - guint8 *signature_length, - gint field_starting_offset) +parse_arg(tvbuff_t *tvb, + packet_info *pinfo, + proto_item *header_item, + guint encoding, + gint offset, + proto_tree *field_tree, + gboolean is_reply_to, + guint8 type_id, + guint8 field_code, + const guint8 **signature, + guint8 *signature_length, + gint field_starting_offset) { gint length; gint padding_start; @@ -889,7 +889,7 @@ parse_arg(tvbuff_t *tvb, static gchar bad_array_format[] = "BAD DATA: Array length (in bytes) is %d. Remaining packet length is %d."; proto_item *item; proto_tree *tree; - guint8 *sig_saved; + const guint8 *sig_saved; gint starting_offset; gint number_of_items = 0; guint8 remaining_sig_length = *signature_length; @@ -931,7 +931,7 @@ parse_arg(tvbuff_t *tvb, advance_to_end_of_signature(signature, &remaining_sig_length); } else { while((offset - starting_offset) < length) { - guint8 *sig_pointer; + const guint8 *sig_pointer; number_of_items++; sig_pointer = sig_saved; @@ -1001,9 +1001,7 @@ parse_arg(tvbuff_t *tvb, proto_tree_add_item(field_tree, hf_alljoyn_mess_body_signature_length, tvb, offset, 1, encoding); offset += 1; - proto_tree_add_item(field_tree, hf_alljoyn_mess_body_signature, tvb, offset, length, ENC_ASCII|ENC_NA); - - *signature = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII); + proto_tree_add_item_ret_string(field_tree, hf_alljoyn_mess_body_signature, tvb, offset, length, ENC_ASCII|ENC_NA, wmem_packet_scope(), signature); if(HDR_SIGNATURE == field_code) { col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", *signature); @@ -1072,6 +1070,9 @@ parse_arg(tvbuff_t *tvb, break; case ARG_STRING: /* AllJoyn UTF-8 NULL terminated string basic type */ + { + const guint8 *member_name; + header_type_name = "string"; padding_start = offset; offset = round_to_4byte(offset, field_starting_offset); @@ -1091,16 +1092,14 @@ parse_arg(tvbuff_t *tvb, length += 1; /* Include the '\0'. */ offset += 4; - proto_tree_add_item(field_tree, hf_alljoyn_string_data, tvb, offset, length, ENC_UTF_8|ENC_NA); + proto_tree_add_item_ret_string(field_tree, hf_alljoyn_string_data, tvb, offset, length, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &member_name); if(HDR_MEMBER == field_code) { - guint8 *member_name; - - member_name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8); col_append_fstr(pinfo->cinfo, COL_INFO, " %s", member_name); } offset += length; + } break; case ARG_UINT64: /* AllJoyn 64-bit unsigned integer basic type */ @@ -1141,11 +1140,11 @@ parse_arg(tvbuff_t *tvb, case ARG_VARIANT: /* AllJoyn variant container type */ { - proto_item *item; - proto_tree *tree; - guint8 *sig_saved; - guint8 *sig_pointer; - guint8 variant_sig_length; + proto_item *item; + proto_tree *tree; + const guint8 *sig_saved; + const guint8 *sig_pointer; + guint8 variant_sig_length; header_type_name = "variant"; @@ -1171,9 +1170,7 @@ parse_arg(tvbuff_t *tvb, offset += 1; tree = proto_item_add_subtree(item, ett_alljoyn_mess_body_parameters); - proto_tree_add_item(tree, hf_alljoyn_mess_body_signature, tvb, offset, length, ENC_ASCII|ENC_NA); - - sig_saved = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_alljoyn_mess_body_signature, tvb, offset, length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &sig_saved); offset += length; sig_pointer = sig_saved; @@ -1318,13 +1315,13 @@ alljoyn_typeid( gchar *result, guint32 type ) * the message. */ static gint -handle_message_field(tvbuff_t *tvb, - packet_info *pinfo, - proto_item *header_tree, - guint encoding, - gint offset, - guint8 **signature, - guint8 *signature_length) +handle_message_field(tvbuff_t *tvb, + packet_info *pinfo, + proto_item *header_tree, + guint encoding, + gint offset, + const guint8 **signature, + guint8 *signature_length) { proto_tree *field_tree; proto_item *item, *field_item; @@ -1394,7 +1391,7 @@ handle_message_field(tvbuff_t *tvb, * @param header_length contains the length of the message fields. * @param signature_length contains the signature field length. */ -static guint8 * +static const guint8 * handle_message_header_fields(tvbuff_t *tvb, packet_info *pinfo, proto_item *header_tree, @@ -1406,7 +1403,7 @@ handle_message_header_fields(tvbuff_t *tvb, gint end_of_header; proto_item *item; proto_tree *tree; - guint8 *signature = NULL; + const guint8 *signature = NULL; item = proto_tree_add_item(header_tree, hf_alljoyn_mess_header_fields, tvb, offset, header_length, ENC_NA); tree = proto_item_add_subtree(item, ett_alljoyn_mess_header); @@ -1430,14 +1427,14 @@ handle_message_header_fields(tvbuff_t *tvb, * @param signature_length contains the signature field length. */ static gint -handle_message_body_parameters(tvbuff_t *tvb, - packet_info *pinfo, - proto_tree *header_tree, - guint encoding, - gint offset, - gint32 body_length, - guint8 *signature, - guint8 signature_length) +handle_message_body_parameters(tvbuff_t *tvb, + packet_info *pinfo, + proto_tree *header_tree, + guint encoding, + gint offset, + gint32 body_length, + const guint8 *signature, + guint8 signature_length) { gint packet_length, end_of_body; proto_tree *tree; @@ -1500,14 +1497,14 @@ handle_message_header_body(tvbuff_t *tvb, proto_item *message_tree, gboolean is_ardp) { - gint remaining_packet_length; - guint8 *signature; - guint8 signature_length = 0; - proto_tree *header_tree, *flag_tree; - proto_item *header_item, *flag_item; - guint encoding; - gint packet_length_needed; - gint header_length = 0, body_length = 0; + gint remaining_packet_length; + const guint8 *signature; + guint8 signature_length = 0; + proto_tree *header_tree, *flag_tree; + proto_item *header_item, *flag_item; + guint encoding; + gint packet_length_needed; + gint header_length = 0, body_length = 0; remaining_packet_length = tvb_reported_length_remaining(tvb, offset); encoding = get_message_header_endianness(tvb, offset); diff --git a/epan/dissectors/packet-amqp.c b/epan/dissectors/packet-amqp.c index 60228b42bf..f6dd7cb326 100644 --- a/epan/dissectors/packet-amqp.c +++ b/epan/dissectors/packet-amqp.c @@ -8263,11 +8263,11 @@ static int dissect_amqp_0_9_method_connection_open(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { + const guint8* vhost; /* virtual-host (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_connection_open_virtual_host, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "vhost=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_connection_open_virtual_host, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &vhost); + col_append_fstr(pinfo->cinfo, COL_INFO, "vhost=%s ", vhost); offset += 1 + tvb_get_guint8(tvb, offset); /* capabilities (shortstr) */ @@ -8322,6 +8322,7 @@ dissect_amqp_0_9_method_connection_close(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { proto_item *tf_code; + const guint8* reply; /* reply-code (short) */ tf_code = proto_tree_add_item(args_tree, hf_amqp_0_9_method_connection_close_reply_code, @@ -8331,10 +8332,9 @@ dissect_amqp_0_9_method_connection_close(tvbuff_t *tvb, packet_info *pinfo, offset += 2; /* reply-text (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_connection_close_reply_text, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "reply=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_connection_close_reply_text, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &reply); + col_append_fstr(pinfo->cinfo, COL_INFO, "reply=%s ", reply); offset += 1 + tvb_get_guint8(tvb, offset); /* class-id (short) */ @@ -8443,6 +8443,7 @@ dissect_amqp_0_9_method_channel_close(guint16 channel_num, tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { proto_item *tf_code; + const guint8* reply; /* reply-code (short) */ tf_code = proto_tree_add_item(args_tree, hf_amqp_method_channel_close_reply_code, @@ -8452,10 +8453,9 @@ dissect_amqp_0_9_method_channel_close(guint16 channel_num, tvbuff_t *tvb, offset += 2; /* reply-text (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_channel_close_reply_text, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "reply=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_channel_close_reply_text, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &reply); + col_append_fstr(pinfo->cinfo, COL_INFO, "reply=%s ", reply); offset += 1 + tvb_get_guint8(tvb, offset); /* class-id (short) */ @@ -8587,6 +8587,7 @@ dissect_amqp_0_9_method_exchange_declare(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { proto_item *ti; + const guint8* exchange; /* ticket (short) */ proto_tree_add_item(args_tree, hf_amqp_method_exchange_declare_ticket, @@ -8594,10 +8595,9 @@ dissect_amqp_0_9_method_exchange_declare(tvbuff_t *tvb, packet_info *pinfo, offset += 2; /* exchange (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_exchange_declare_exchange, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_exchange_declare_exchange, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &exchange); + col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", exchange); offset += 1 + tvb_get_guint8(tvb, offset); /* type (shortstr) */ @@ -8652,6 +8652,7 @@ dissect_amqp_0_9_method_exchange_bind(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { proto_item *ti; + const guint8* str; /* ticket (short) */ proto_tree_add_item(args_tree, hf_amqp_method_exchange_declare_ticket, @@ -8659,24 +8660,21 @@ dissect_amqp_0_9_method_exchange_bind(tvbuff_t *tvb, packet_info *pinfo, offset += 2; /* destination (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_exchange_bind_destination, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "dx=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_exchange_bind_destination, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "dx=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* source (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_exchange_bind_source, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "sx=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_exchange_bind_source, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "sx=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* routing-key (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_exchange_bind_routing_key, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "bk=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_exchange_bind_routing_key, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "bk=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* nowait (bit) */ @@ -8709,16 +8707,17 @@ static int dissect_amqp_0_9_method_exchange_delete(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { + const guint8* exchange; + /* ticket (short) */ proto_tree_add_item(args_tree, hf_amqp_method_exchange_delete_ticket, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* exchange (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_exchange_delete_exchange, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_exchange_delete_exchange, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &exchange); + col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", exchange); offset += 1 + tvb_get_guint8(tvb, offset); /* if-unused (bit) */ @@ -8748,6 +8747,7 @@ dissect_amqp_0_9_method_queue_declare(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { proto_item *ti; + const guint8* queue; /* ticket (short) */ proto_tree_add_item(args_tree, hf_amqp_method_queue_declare_ticket, @@ -8755,10 +8755,9 @@ dissect_amqp_0_9_method_queue_declare(tvbuff_t *tvb, packet_info *pinfo, offset += 2; /* queue (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_queue_declare_queue, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_queue_declare_queue, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &queue); + col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", queue); offset += 1 + tvb_get_guint8(tvb, offset); /* passive (bit) */ @@ -8798,11 +8797,12 @@ static int dissect_amqp_0_9_method_queue_declare_ok(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { + const guint8* queue; + /* queue (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_queue_declare_ok_queue, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_queue_declare_ok_queue, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &queue); + col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", queue); offset += 1 + tvb_get_guint8(tvb, offset); /* message-count (long) */ @@ -8825,6 +8825,7 @@ dissect_amqp_0_9_method_queue_bind(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { proto_item *ti; + const guint8* str; /* ticket (short) */ proto_tree_add_item(args_tree, hf_amqp_method_queue_bind_ticket, @@ -8832,24 +8833,21 @@ dissect_amqp_0_9_method_queue_bind(tvbuff_t *tvb, packet_info *pinfo, offset += 2; /* queue (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_queue_bind_queue, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_queue_bind_queue, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* exchange (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_queue_bind_exchange, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_queue_bind_exchange, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* routing-key (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_queue_bind_routing_key, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "bk=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_queue_bind_routing_key, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "bk=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* nowait (bit) */ @@ -8883,6 +8881,7 @@ dissect_amqp_0_9_method_queue_unbind(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { proto_item *ti; + const guint8* str; /* ticket (short) */ proto_tree_add_item(args_tree, hf_amqp_method_queue_unbind_ticket, @@ -8890,24 +8889,21 @@ dissect_amqp_0_9_method_queue_unbind(tvbuff_t *tvb, packet_info *pinfo, offset += 2; /* queue (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_queue_unbind_queue, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_queue_unbind_queue, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* exchange (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_queue_unbind_exchange, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_queue_unbind_exchange, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* routing-key (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_queue_unbind_routing_key, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "rk=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_queue_unbind_routing_key, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "rk=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* arguments (table) */ @@ -8935,16 +8931,17 @@ static int dissect_amqp_0_9_method_queue_purge(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { + const guint8* queue; + /* ticket (short) */ proto_tree_add_item(args_tree, hf_amqp_method_queue_purge_ticket, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* queue (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_queue_purge_queue, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_queue_purge_queue, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &queue); + col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", queue); offset += 1 + tvb_get_guint8(tvb, offset); /* nowait (bit) */ @@ -8974,16 +8971,17 @@ static int dissect_amqp_0_9_method_queue_delete(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { + const guint8* queue; + /* ticket (short) */ proto_tree_add_item(args_tree, hf_amqp_method_queue_delete_ticket, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* queue (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_queue_delete_queue, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_queue_delete_queue, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &queue); + col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", queue); offset += 1 + tvb_get_guint8(tvb, offset); /* if-unused (bit) */ @@ -9054,6 +9052,7 @@ dissect_amqp_0_9_method_basic_consume(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { proto_item *ti; + const guint8* queue; /* ticket (short) */ proto_tree_add_item(args_tree, hf_amqp_method_basic_consume_ticket, @@ -9061,10 +9060,9 @@ dissect_amqp_0_9_method_basic_consume(tvbuff_t *tvb, packet_info *pinfo, offset += 2; /* queue (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_basic_consume_queue, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_basic_consume_queue, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &queue); + col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", queue); offset += 1 + tvb_get_guint8(tvb, offset); /* consumer-tag (shortstr) */ @@ -9153,6 +9151,7 @@ dissect_amqp_0_9_method_basic_publish(guint16 channel_num, { amqp_delivery *delivery; proto_item *pi; + const guint8* str; /* message number (long long) */ if(!PINFO_FD_VISITED(pinfo)) @@ -9181,17 +9180,15 @@ dissect_amqp_0_9_method_basic_publish(guint16 channel_num, offset += 2; /* exchange (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_basic_publish_exchange, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_basic_publish_exchange, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* routing-key (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_basic_publish_routing_key, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "rk=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_basic_publish_routing_key, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "rk=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* mandatory (bit) */ @@ -9245,6 +9242,7 @@ dissect_amqp_0_9_method_basic_deliver(guint16 channel_num, tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { guint64 delivery_tag; + const guint8* str; /* consumer-tag (shortstr) */ proto_tree_add_item(args_tree, hf_amqp_method_basic_deliver_consumer_tag, @@ -9263,17 +9261,15 @@ dissect_amqp_0_9_method_basic_deliver(guint16 channel_num, offset += 1; /* exchange (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_basic_deliver_exchange, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_basic_deliver_exchange, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* routing-key (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_basic_deliver_routing_key, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "rk=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_basic_deliver_routing_key, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "rk=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); if(!PINFO_FD_VISITED(pinfo)) @@ -9288,16 +9284,17 @@ static int dissect_amqp_0_9_method_basic_get(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { + const guint8* queue; + /* ticket (short) */ proto_tree_add_item(args_tree, hf_amqp_method_basic_get_ticket, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* queue (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_basic_get_queue, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_basic_get_queue, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &queue); + col_append_fstr(pinfo->cinfo, COL_INFO, "q=%s ", queue); offset += 1 + tvb_get_guint8(tvb, offset); /* no-ack (bit) */ @@ -9314,6 +9311,7 @@ dissect_amqp_0_9_method_basic_get_ok(guint16 channel_num, tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *args_tree) { guint64 delivery_tag; + const guint8* str; /* delivery-tag (longlong) */ proto_tree_add_item(args_tree, hf_amqp_method_basic_get_ok_delivery_tag, @@ -9327,17 +9325,15 @@ dissect_amqp_0_9_method_basic_get_ok(guint16 channel_num, offset += 1; /* exchange (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_basic_get_ok_exchange, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_basic_get_ok_exchange, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "x=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* routing-key (shortstr) */ - proto_tree_add_item(args_tree, hf_amqp_method_basic_get_ok_routing_key, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "rk=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(args_tree, hf_amqp_method_basic_get_ok_routing_key, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + col_append_fstr(pinfo->cinfo, COL_INFO, "rk=%s ", str); offset += 1 + tvb_get_guint8(tvb, offset); /* message-count (long) */ @@ -10160,18 +10156,18 @@ static int dissect_amqp_0_9_content_header_basic(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *prop_tree) { - proto_item *ti; - guint16 prop_flags; - nstime_t tv; + proto_item *ti; + guint16 prop_flags; + nstime_t tv; + const guint8 *content; prop_flags = tvb_get_ntohs(tvb, 19); if (prop_flags & 0x8000) { /* content-type (shortstr) */ - proto_tree_add_item(prop_tree, hf_amqp_header_basic_content_type, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "type=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(prop_tree, hf_amqp_header_basic_content_type, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &content); + col_append_fstr(pinfo->cinfo, COL_INFO, "type=%s ", content); offset += 1 + tvb_get_guint8(tvb, offset); } prop_flags <<= 1; @@ -10292,18 +10288,18 @@ static int dissect_amqp_0_9_content_header_file(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *prop_tree) { - proto_item *ti; - guint16 prop_flags; - nstime_t tv; + proto_item *ti; + guint16 prop_flags; + nstime_t tv; + const guint8 *content; prop_flags = tvb_get_ntohs(tvb, 19); if (prop_flags & 0x8000) { /* content-type (shortstr) */ - proto_tree_add_item(prop_tree, hf_amqp_header_file_content_type, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "type=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(prop_tree, hf_amqp_header_file_content_type, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &content); + col_append_fstr(pinfo->cinfo, COL_INFO, "type=%s ", content); offset += 1 + tvb_get_guint8(tvb, offset); } prop_flags <<= 1; @@ -10383,18 +10379,18 @@ static int dissect_amqp_0_9_content_header_stream(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *prop_tree) { - proto_item *ti; - guint16 prop_flags; - nstime_t tv; + proto_item *ti; + guint16 prop_flags; + nstime_t tv; + const guint8 *content; prop_flags = tvb_get_ntohs(tvb, 19); if (prop_flags & 0x8000) { /* content-type (shortstr) */ - proto_tree_add_item(prop_tree, hf_amqp_header_stream_content_type, - tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "type=%s ", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(prop_tree, hf_amqp_header_stream_content_type, + tvb, offset + 1, tvb_get_guint8(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &content); + col_append_fstr(pinfo->cinfo, COL_INFO, "type=%s ", content); offset += 1 + tvb_get_guint8(tvb, offset); } prop_flags <<= 1; diff --git a/epan/dissectors/packet-ansi_map.c b/epan/dissectors/packet-ansi_map.c index 793389b34b..96fab2fa69 100644 --- a/epan/dissectors/packet-ansi_map.c +++ b/epan/dissectors/packet-ansi_map.c @@ -1487,14 +1487,18 @@ dissect_ansi_map_digits_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree proto_item_append_text(actx->created_item, " - %s", digit_str); break; case 2: + { + const guint8* digits; /* IA5 Coding */ octet_len = tvb_get_guint8(tvb,offset); proto_tree_add_item(subtree, hf_ansi_map_nr_digits, tvb, offset, 1, ENC_BIG_ENDIAN); if(octet_len == 0) return; offset++; - proto_tree_add_item(subtree, hf_ansi_map_ia5_digits, tvb, offset, -1, ENC_ASCII|ENC_NA); - proto_item_append_text(actx->created_item, " - %s", tvb_get_string_enc(wmem_packet_scope(),tvb,offset,tvb_reported_length_remaining(tvb,offset),ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(subtree, hf_ansi_map_ia5_digits, tvb, offset, tvb_reported_length_remaining(tvb,offset), + ENC_ASCII|ENC_NA, wmem_packet_scope(), &digits); + proto_item_append_text(actx->created_item, " - %s", digits); + } break; case 3: /* Octet string */ @@ -1525,9 +1529,13 @@ dissect_ansi_map_digits_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree proto_item_append_text(actx->created_item, " - %s", digit_str); break; case 2: + { + const guint8* digits; /* IA5 Coding */ - proto_tree_add_item(subtree, hf_ansi_map_ia5_digits, tvb, offset, -1, ENC_ASCII|ENC_NA); - proto_item_append_text(actx->created_item, " - %s", tvb_get_string_enc(wmem_packet_scope(),tvb,offset,tvb_reported_length_remaining(tvb,offset),ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(subtree, hf_ansi_map_ia5_digits, tvb, offset, tvb_reported_length_remaining(tvb,offset), + ENC_ASCII|ENC_NA, wmem_packet_scope(), &digits); + proto_item_append_text(actx->created_item, " - %s", digits); + } break; case 3: /* Octet string */ @@ -15278,7 +15286,7 @@ dissect_ansi_map_QualificationRequest2Res(gboolean implicit_tag _U_, tvbuff_t *t /*--- End of included file: packet-ansi_map-fn.c ---*/ -#line 3633 "./asn1/ansi_map/packet-ansi_map-template.c" +#line 3641 "./asn1/ansi_map/packet-ansi_map-template.c" /* * 6.5.2.dk N.S0013-0 v 1.0,X.S0004-550-E v1.0 2.301 @@ -19227,7 +19235,7 @@ void proto_register_ansi_map(void) { NULL, HFILL }}, /*--- End of included file: packet-ansi_map-hfarr.c ---*/ -#line 5389 "./asn1/ansi_map/packet-ansi_map-template.c" +#line 5397 "./asn1/ansi_map/packet-ansi_map-template.c" }; /* List of subtrees */ @@ -19488,7 +19496,7 @@ void proto_register_ansi_map(void) { &ett_ansi_map_ReturnData, /*--- End of included file: packet-ansi_map-ettarr.c ---*/ -#line 5422 "./asn1/ansi_map/packet-ansi_map-template.c" +#line 5430 "./asn1/ansi_map/packet-ansi_map-template.c" }; static ei_register_info ei[] = { diff --git a/epan/dissectors/packet-ar_drone.c b/epan/dissectors/packet-ar_drone.c index fe71f0940f..b98a4ba20d 100644 --- a/epan/dissectors/packet-ar_drone.c +++ b/epan/dissectors/packet-ar_drone.c @@ -519,6 +519,8 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data }else if (!strncmp(command, "AT*CTRL", 7)) { + const guint8* CTRL_mode_str; + /** Parse according to the CTRL layout: */ sub_tree = proto_item_add_subtree(sub_item, ett_CTRL); @@ -539,9 +541,8 @@ dissect_ar_drone(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data expert_add_info(pinfo, sub_item, &ei_NO_COMMA); return offset; } - ti = proto_tree_add_item(sub_tree, hf_CTRL_mode, tvb, offset, length, ENC_ASCII|ENC_NA); - proto_item_append_text(ti, "%s", - str_to_str(tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII|ENC_NA), CTRL_mode_vs, " (Unknown Mode)")); + ti = proto_tree_add_item_ret_string(sub_tree, hf_CTRL_mode, tvb, offset, length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &CTRL_mode_str); + proto_item_append_text(ti, "%s", str_to_str(CTRL_mode_str, CTRL_mode_vs, " (Unknown Mode)")); offset += (length + 1); /* Add File Size */ diff --git a/epan/dissectors/packet-artnet.c b/epan/dissectors/packet-artnet.c index 2723a111a8..90b29c2e6e 100644 --- a/epan/dissectors/packet-artnet.c +++ b/epan/dissectors/packet-artnet.c @@ -3172,34 +3172,25 @@ dissect_artnet_file_fn_reply(tvbuff_t *tvb _U_, guint offset, proto_tree *tree _ static int dissect_artnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { - gint offset = 0; - guint size; - guint16 opcode; - proto_tree *ti = NULL, *hi = NULL, *si = NULL, *artnet_tree = NULL, *artnet_header_tree = NULL; + gint offset = 0; + guint size; + guint16 opcode; + const guint8 *header; + proto_tree *ti, *hi, *si = NULL, *artnet_tree, *artnet_header_tree; col_set_str(pinfo->cinfo, COL_PROTOCOL, "ARTNET"); col_clear(pinfo->cinfo, COL_INFO); - if (tree) { - ti = proto_tree_add_item(tree, proto_artnet, tvb, offset, -1, ENC_NA); - artnet_tree = proto_item_add_subtree(ti, ett_artnet); - - hi = proto_tree_add_item(artnet_tree, - hf_artnet_header, - tvb, - offset, - ARTNET_HEADER_LENGTH , - ENC_NA); + ti = proto_tree_add_item(tree, proto_artnet, tvb, offset, -1, ENC_NA); + artnet_tree = proto_item_add_subtree(ti, ett_artnet); - artnet_header_tree = proto_item_add_subtree(hi, ett_artnet); - } + hi = proto_tree_add_item(artnet_tree, hf_artnet_header, tvb, + offset, ARTNET_HEADER_LENGTH, ENC_NA); + artnet_header_tree = proto_item_add_subtree(hi, ett_artnet); - col_append_fstr(pinfo->cinfo, COL_INFO, "%s", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 8, ENC_ASCII|ENC_NA)); - if (tree) { - proto_tree_add_item(artnet_header_tree, hf_artnet_header_id, - tvb, offset, 8, ENC_ASCII|ENC_NA); - } + proto_tree_add_item_ret_string(artnet_header_tree, hf_artnet_header_id, + tvb, offset, 8, ENC_ASCII|ENC_NA, wmem_packet_scope(), &header); + col_append_fstr(pinfo->cinfo, COL_INFO, "%s", header); offset += 8; opcode = tvb_get_letohs(tvb, offset); diff --git a/epan/dissectors/packet-bfd.c b/epan/dissectors/packet-bfd.c index c9b1d9553f..ab839d6954 100644 --- a/epan/dissectors/packet-bfd.c +++ b/epan/dissectors/packet-bfd.c @@ -306,13 +306,13 @@ get_bfd_checksum_len(guint8 auth_type) static void dissect_bfd_authentication(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - int offset = 24; - guint8 auth_type; - guint8 auth_len; - proto_item *ti = NULL; - proto_item *auth_item = NULL; - proto_tree *auth_tree = NULL; - guint8 *password; + int offset = 24; + guint8 auth_type; + guint8 auth_len; + proto_item *ti = NULL; + proto_item *auth_item = NULL; + proto_tree *auth_tree = NULL; + const guint8 *password; auth_type = tvb_get_guint8(tvb, offset); auth_len = tvb_get_guint8(tvb, offset + 1); @@ -334,12 +334,9 @@ dissect_bfd_authentication(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) switch (auth_type) { case BFD_AUTH_SIMPLE: - if (tree) { - password = tvb_get_string_enc(wmem_packet_scope(), tvb, offset+3, auth_len-3, ENC_ASCII); - proto_tree_add_string(auth_tree, hf_bfd_auth_password, tvb, offset+3, - auth_len-3, password); - proto_item_append_text(auth_item, ": %s", password); - } + proto_tree_add_item_ret_string(auth_tree, hf_bfd_auth_password, tvb, offset+3, + auth_len-3, ENC_ASCII|ENC_NA, wmem_packet_scope(), &password); + proto_item_append_text(auth_item, ": %s", password); break; case BFD_AUTH_MD5: case BFD_AUTH_MET_MD5: diff --git a/epan/dissectors/packet-bitcoin.c b/epan/dissectors/packet-bitcoin.c index 4c00209bff..56c8259aa6 100644 --- a/epan/dissectors/packet-bitcoin.c +++ b/epan/dissectors/packet-bitcoin.c @@ -1540,9 +1540,9 @@ dissect_bitcoin_msg_empty(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre static int dissect_bitcoin_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { - proto_item *ti; - guint32 offset = 0; - guint8* command; + proto_item *ti; + guint32 offset = 0; + const guint8* command; dissector_handle_t command_handle; col_set_str(pinfo->cinfo, COL_PROTOCOL, "Bitcoin"); @@ -1552,13 +1552,12 @@ static int dissect_bitcoin_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree /* add basic protocol data */ proto_tree_add_item(tree, &hfi_bitcoin_magic, tvb, 0, 4, ENC_BIG_ENDIAN); - proto_tree_add_item(tree, &hfi_bitcoin_command, tvb, 4, 12, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(tree, hfi_bitcoin_command.id, tvb, 4, 12, ENC_ASCII|ENC_NA, wmem_packet_scope(), &command); proto_tree_add_item(tree, &hfi_bitcoin_length, tvb, 16, 4, ENC_LITTLE_ENDIAN); proto_tree_add_item(tree, &hfi_bitcoin_checksum, tvb, 20, 4, ENC_BIG_ENDIAN); offset = 24; - command = tvb_get_string_enc(wmem_packet_scope(), tvb, 4, 12, ENC_ASCII|ENC_NA); command_handle = dissector_get_string_handle(bitcoin_command_table, command); if (command_handle != NULL) { diff --git a/epan/dissectors/packet-bootp.c b/epan/dissectors/packet-bootp.c index 85d524cc7a..cd10526484 100644 --- a/epan/dissectors/packet-bootp.c +++ b/epan/dissectors/packet-bootp.c @@ -2921,7 +2921,7 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, proto_item case 242: { /* Avaya IP Telephone */ proto_tree *o242avaya_v_tree; proto_item *avaya_ti; - gchar *avaya_option = NULL; + const guint8 *avaya_option = NULL; gchar *field = NULL; wmem_strbuf_t *avaya_param_buf = NULL; @@ -2931,11 +2931,10 @@ bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, proto_item optoff += optlen; break; } - avaya_option = (gchar*)tvb_get_string_enc(wmem_packet_scope(), tvb, optoff, optlen, ENC_ASCII); - avaya_ti = proto_tree_add_string(v_tree, hf_bootp_option242_avaya, tvb, optoff, optlen, avaya_option); + avaya_ti = proto_tree_add_item_ret_string(v_tree, hf_bootp_option242_avaya, tvb, optoff, optlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &avaya_option); o242avaya_v_tree = proto_item_add_subtree(avaya_ti, ett_bootp_option242_suboption); avaya_param_buf = wmem_strbuf_new(wmem_packet_scope(), ""); - for ( field = strtok(avaya_option, ","); field; field = strtok(NULL, ",") ) { + for ( field = strtok((char*)avaya_option, ","); field; field = strtok(NULL, ",") ) { if (!strchr(field, '=')) { if (wmem_strbuf_get_len(avaya_param_buf) == 0) { expert_add_info_format(pinfo, vti, &hf_bootp_subopt_unknown_type, "ERROR, Unknown parameter %s", field); diff --git a/epan/dissectors/packet-btavrcp.c b/epan/dissectors/packet-btavrcp.c index 5fcbc29b1c..23ed1e63cc 100644 --- a/epan/dissectors/packet-btavrcp.c +++ b/epan/dissectors/packet-btavrcp.c @@ -1884,7 +1884,7 @@ dissect_browsing(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint folder_name_length; proto_item *pitem; proto_tree *ptree; - guint8 *folder_name; + const guint8 *folder_name; proto_tree_add_item(tree, hf_btavrcp_uid_counter, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; @@ -1904,8 +1904,7 @@ dissect_browsing(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree_add_item(ptree, hf_btavrcp_folder_name_length, tvb, offset, 2, ENC_BIG_ENDIAN); folder_name_length = tvb_get_ntohs(tvb, offset); offset += 2; - proto_tree_add_item(ptree, hf_btavrcp_folder_name, tvb, offset, folder_name_length, ENC_NA); - folder_name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, folder_name_length, ENC_ASCII); + proto_tree_add_item_ret_string(ptree, hf_btavrcp_folder_name, tvb, offset, folder_name_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &folder_name); offset += folder_name_length; proto_item_append_text(pitem, "%s/", folder_name); col_append_fstr(pinfo->cinfo, COL_INFO, "%s/", folder_name); diff --git a/epan/dissectors/packet-bthcrp.c b/epan/dissectors/packet-bthcrp.c index 27caf65308..93cae59773 100644 --- a/epan/dissectors/packet-bthcrp.c +++ b/epan/dissectors/packet-bthcrp.c @@ -245,10 +245,9 @@ dissect_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, col_append_fstr(pinfo->cinfo, COL_INFO, ", Number Of Bytes: %u", number); offset += 2; } else { - guint8 *id; + const guint8 *id; - proto_tree_add_item(tree, hf_bthcrp_control_1284_id, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII | ENC_NA); - id = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_bthcrp_control_1284_id, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII | ENC_NA, wmem_packet_scope(), &id); col_append_fstr(pinfo->cinfo, COL_INFO, " - 1284 ID: %s", id); offset += tvb_reported_length_remaining(tvb, offset); } diff --git a/epan/dissectors/packet-btsdp.c b/epan/dissectors/packet-btsdp.c index 6d1eeabdea..19cfd560cd 100644 --- a/epan/dissectors/packet-btsdp.c +++ b/epan/dissectors/packet-btsdp.c @@ -2145,7 +2145,7 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, guint i_feature; guint i_protocol; guint16 psm; - guint8 *new_str; + const guint8 *new_str; guint32 value; guint64 value_64; bluetooth_uuid_t uuid; @@ -2525,23 +2525,19 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, case BTSDP_HCRP_SCAN_SERVICE_UUID: switch (attribute) { case 0x300: - proto_tree_add_item(next_tree, hf_hcrp_1284_id, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_hcrp_1284_id, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x302: - proto_tree_add_item(next_tree, hf_hcrp_device_name, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_hcrp_device_name, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x304: - proto_tree_add_item(next_tree, hf_hcrp_friendly_name, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_hcrp_friendly_name, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x306: - proto_tree_add_item(next_tree, hf_hcrp_device_location, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_hcrp_device_location, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; default: @@ -2561,8 +2557,7 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, wmem_strbuf_append(info_buf, val_to_str_const(value, wap_gateway_vals, "Unknown")); break; case 0x308: - proto_tree_add_item(next_tree, hf_wap_homepage_url, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_wap_homepage_url, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x309: @@ -2626,6 +2621,8 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, entry_offset += length; if (entry_length - (entry_offset - list_offset) > 0) { + const guint8* entry_str; + entry_item = proto_tree_add_item(sub_tree, hf_hdp_supported_features_data_mdep_description, tvb, entry_offset, entry_length, ENC_NA); entry_tree = proto_item_add_subtree(entry_item, ett_btsdp_supported_features_mdep_description); @@ -2633,8 +2630,9 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, new_offset = get_type_length(tvb, entry_offset, &length); proto_item_set_len(entry_item, (new_offset - entry_offset) + length); entry_offset = new_offset; - proto_tree_add_item(next_tree, hf_hdp_supported_features_mdep_description, tvb, entry_offset, length, ENC_ASCII | ENC_NA); - proto_item_append_text(entry_item, ": %s", tvb_get_string_enc(wmem_packet_scope(), tvb, entry_offset, length, ENC_ASCII)); + proto_tree_add_item_ret_string(next_tree, hf_hdp_supported_features_mdep_description, tvb, entry_offset, length, + ENC_ASCII | ENC_NA, wmem_packet_scope(), &entry_str); + proto_item_append_text(entry_item, ": %s", entry_str); entry_offset += length; } @@ -2675,13 +2673,11 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, break; case 0x30D: case 0x200: - proto_tree_add_item(next_tree, hf_pan_ipv4_subnet, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_pan_ipv4_subnet, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x30E: - proto_tree_add_item(next_tree, hf_pan_ipv6_subnet, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_pan_ipv6_subnet, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; default: @@ -2707,13 +2703,11 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, break; case 0x30D: case 0x200: - proto_tree_add_item(next_tree, hf_pan_ipv4_subnet, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_pan_ipv4_subnet, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x30E: - proto_tree_add_item(next_tree, hf_pan_ipv6_subnet, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_pan_ipv6_subnet, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; default: @@ -2764,8 +2758,7 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, wmem_strbuf_append(info_buf, supported_features ? "true" : "false"); break; case 0x306: - proto_tree_add_item(next_tree, hf_dun_escape_sequence, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_dun_escape_sequence, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; default: @@ -3133,8 +3126,7 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, case BTSDP_BPP_REFERENCE_PRINTING_SERVICE_UUID: switch (attribute) { case 0x350: - proto_tree_add_item(next_tree, hf_bpp_document_formats_supported, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_bpp_document_formats_supported, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x352: @@ -3143,8 +3135,7 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, wmem_strbuf_append(info_buf, new_str); break; case 0x354: - proto_tree_add_item(next_tree, hf_bpp_xhtml_print_image_formats_supported, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_bpp_xhtml_print_image_formats_supported, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x356: @@ -3153,18 +3144,15 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, wmem_strbuf_append(info_buf, value ? "true" : "false"); break; case 0x358: - proto_tree_add_item(next_tree, hf_bpp_1284_id, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_bpp_1284_id, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x35A: - proto_tree_add_item(next_tree, hf_bpp_printer_name, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_bpp_printer_name, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x35C: - proto_tree_add_item(next_tree, hf_bpp_printer_location, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_bpp_printer_location, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x35E: @@ -3173,8 +3161,7 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, wmem_strbuf_append(info_buf, value ? "true" : "false"); break; case 0x360: - proto_tree_add_item(next_tree, hf_bpp_media_types_supported, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_bpp_media_types_supported, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x362: @@ -3193,8 +3180,7 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, wmem_strbuf_append(info_buf, value ? "true" : "false"); break; case 0x368: - proto_tree_add_item(next_tree, hf_bpp_rui_formats_supported, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_bpp_rui_formats_supported, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x370: @@ -3208,18 +3194,15 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, wmem_strbuf_append(info_buf, value ? "true" : "false"); break; case 0x374: - proto_tree_add_item(next_tree, hf_bpp_reference_printing_top_url, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_bpp_reference_printing_top_url, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x376: - proto_tree_add_item(next_tree, hf_bpp_direct_printing_top_url, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_bpp_direct_printing_top_url, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x37A: - proto_tree_add_item(next_tree, hf_bpp_device_name, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_bpp_device_name, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; default: @@ -3229,13 +3212,11 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, case BTSDP_BPP_REFLECTED_UI_SERVICE_UUID: switch (attribute) { case 0x368: - proto_tree_add_item(next_tree, hf_bpp_rui_formats_supported, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_bpp_rui_formats_supported, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x378: - proto_tree_add_item(next_tree, hf_bpp_printer_admin_rui_top_url, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_bpp_printer_admin_rui_top_url, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; default: @@ -3357,10 +3338,9 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, dissect_data_element(entry_tree, &sub_tree, pinfo, tvb, list_offset); list_offset = get_type_length(tvb, list_offset, &entry_length); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, list_offset, entry_length, ENC_ASCII); + proto_tree_add_item_ret_string(sub_tree, hf_sdp_lang_code, tvb, list_offset, entry_length, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append_printf(info_buf, "Lang: %s", new_str); proto_item_append_text(entry_item, ": Lang: %s", new_str); - proto_tree_add_item(sub_tree, hf_sdp_lang_code, tvb, list_offset, entry_length, ENC_ASCII | ENC_NA); list_offset += entry_length; dissect_data_element(entry_tree, &sub_tree, pinfo, tvb, list_offset); @@ -3434,18 +3414,15 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, } break; case 0x00A: - proto_tree_add_item(next_tree, hf_sdp_service_documentation_url, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_sdp_service_documentation_url, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x00B: - proto_tree_add_item(next_tree, hf_sdp_service_client_executable_url, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_sdp_service_client_executable_url, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x00C: - proto_tree_add_item(next_tree, hf_sdp_service_icon_url, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_sdp_service_icon_url, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x00D: @@ -3472,18 +3449,15 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, } break; case 0x100: - proto_tree_add_item(next_tree, hf_sdp_service_name, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_sdp_service_name, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x101: - proto_tree_add_item(next_tree, hf_sdp_service_description, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_sdp_service_description, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; case 0x102: - proto_tree_add_item(next_tree, hf_sdp_service_provider_name, tvb, offset, size, ENC_ASCII | ENC_NA); - new_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, hf_sdp_service_provider_name, tvb, offset, size, ENC_ASCII | ENC_NA, wmem_packet_scope(), &new_str); wmem_strbuf_append(info_buf, new_str); break; default: @@ -3514,9 +3488,9 @@ dissect_sdp_type(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, break; case 8: /* fall through */ case 4: { - gchar *ptr = (gchar*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, size, ENC_ASCII); + const guint8 *ptr; - proto_tree_add_item(next_tree, (type == 8) ? hf_data_element_value_url : hf_data_element_value_string, tvb, offset, size, ENC_NA | ENC_ASCII); + proto_tree_add_item_ret_string(next_tree, (type == 8) ? hf_data_element_value_url : hf_data_element_value_string, tvb, offset, size, ENC_NA | ENC_ASCII, wmem_packet_scope(), &ptr); wmem_strbuf_append_printf(info_buf, "%s ", ptr); break; } diff --git a/epan/dissectors/packet-c1222.c b/epan/dissectors/packet-c1222.c index 1971ca940d..b83fcd7541 100644 --- a/epan/dissectors/packet-c1222.c +++ b/epan/dissectors/packet-c1222.c @@ -425,8 +425,8 @@ static void parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cmd, guint32 *length, int *offset) { guint16 user_id = 0; - guint8 *user_name = NULL; - guint8 *password = NULL; + const guint8 *user_name = NULL; + const guint8 *password = NULL; guint8 auth_len = 0; gchar *auth_req = NULL; guint16 table = 0; @@ -459,8 +459,7 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm user_id = tvb_get_ntohs(tvb, *offset); proto_tree_add_uint(tree, hf_c1222_logon_id, tvb, *offset, 2, user_id); *offset += 2; - user_name = tvb_get_string_enc(wmem_packet_scope(),tvb, *offset, 10, ENC_ASCII); - proto_tree_add_string(tree, hf_c1222_logon_user, tvb, *offset, 10, user_name); + proto_tree_add_item_ret_string(tree, hf_c1222_logon_user, tvb, *offset, 10, ENC_ASCII|ENC_NA, wmem_packet_scope(), &user_name); *offset += 10; *length -= 12; proto_item_set_text(tree, "C12.22 EPSEM: %s (id %d, user \"%s\")", @@ -471,8 +470,7 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm break; case C1222_CMD_SECURITY: if (*length >= 20) { - password = tvb_get_string_enc(wmem_packet_scope(),tvb, *offset, 20, ENC_ASCII); - proto_tree_add_string(tree, hf_c1222_security_password, tvb, *offset, 20, password); + proto_tree_add_item_ret_string(tree, hf_c1222_security_password, tvb, *offset, 20, ENC_ASCII|ENC_NA, wmem_packet_scope(), &password); *offset += 20; *length -= 20; if (*length >= 2) { @@ -1568,7 +1566,7 @@ static int dissect_MESSAGE_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_ /*--- End of included file: packet-c1222-fn.c ---*/ -#line 1050 "./asn1/c1222/packet-c1222-template.c" +#line 1048 "./asn1/c1222/packet-c1222-template.c" /** * Dissects a a full (reassembled) C12.22 message. @@ -1954,7 +1952,7 @@ void proto_register_c1222(void) { "OCTET_STRING_SIZE_CONSTR002", HFILL }}, /*--- End of included file: packet-c1222-hfarr.c ---*/ -#line 1331 "./asn1/c1222/packet-c1222-template.c" +#line 1329 "./asn1/c1222/packet-c1222-template.c" }; /* List of subtrees */ @@ -1977,7 +1975,7 @@ void proto_register_c1222(void) { &ett_c1222_Calling_authentication_value_c1221_U, /*--- End of included file: packet-c1222-ettarr.c ---*/ -#line 1341 "./asn1/c1222/packet-c1222-template.c" +#line 1339 "./asn1/c1222/packet-c1222-template.c" }; static ei_register_info ei[] = { diff --git a/epan/dissectors/packet-catapult-dct2000.c b/epan/dissectors/packet-catapult-dct2000.c index b43a6f017f..0929be6990 100644 --- a/epan/dissectors/packet-catapult-dct2000.c +++ b/epan/dissectors/packet-catapult-dct2000.c @@ -2456,11 +2456,11 @@ dissect_catapult_dct2000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo if (strcmp(protocol_name, "comment") == 0) { /* Extract & add the string. */ proto_item *string_ti; - char *string = (char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII); + const guint8 *string; /* Show comment string */ - string_ti = proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_comment, tvb, - offset, -1, ENC_ASCII|ENC_NA); + string_ti = proto_tree_add_item_ret_string(dct2000_tree, hf_catapult_dct2000_comment, tvb, + offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &string); col_append_fstr(pinfo->cinfo, COL_INFO, "%s", string); if (catapult_dct2000_dissect_mac_lte_oob_messages) { @@ -2483,11 +2483,11 @@ dissect_catapult_dct2000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, vo else if (strcmp(protocol_name, "sprint") == 0) { /* Extract & add the string. */ - char *string = (char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII); + const guint8 *string; /* Show sprint string */ - proto_tree_add_item(dct2000_tree, hf_catapult_dct2000_sprint, tvb, - offset, -1, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(dct2000_tree, hf_catapult_dct2000_sprint, tvb, + offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII|ENC_NA, wmem_packet_scope(), &string); col_append_fstr(pinfo->cinfo, COL_INFO, "%s", string); return tvb_captured_length(tvb); diff --git a/epan/dissectors/packet-cell_broadcast.c b/epan/dissectors/packet-cell_broadcast.c index b3fd231f6c..608af7463a 100644 --- a/epan/dissectors/packet-cell_broadcast.c +++ b/epan/dissectors/packet-cell_broadcast.c @@ -338,13 +338,11 @@ dissect_gsm_cell_broadcast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *cbs_page_subtree = proto_tree_add_subtree(cbs_page_tree, tvb, offset, -1, ett_gsm_cbs_page_content, NULL, "Cell Broadcast Page Contents"); len = tvb_reported_length(cbs_page_tvb); - proto_tree_add_string(cbs_page_subtree, hf_gsm_cbs_page_content, cbs_page_tvb, 0, - text_len, tvb_get_string_enc(wmem_packet_scope(), cbs_page_tvb, 0, text_len, ENC_ASCII)); + proto_tree_add_item(cbs_page_subtree, hf_gsm_cbs_page_content, cbs_page_tvb, 0, text_len, ENC_ASCII|ENC_NA); len -= text_len; if (len) { - proto_tree_add_string(cbs_page_subtree, hf_gsm_cbs_page_content_padding, cbs_page_tvb, text_len, len, - tvb_get_string_enc(wmem_packet_scope(), cbs_page_tvb, text_len, len, ENC_ASCII)); + proto_tree_add_item(cbs_page_subtree, hf_gsm_cbs_page_content_padding, cbs_page_tvb, text_len, len, ENC_ASCII|ENC_NA); } } if (text_len) @@ -380,7 +378,7 @@ dissect_gsm_cell_broadcast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, cbs_msg_item = proto_tree_add_protocol_format(proto_tree_get_root(tree), proto_cell_broadcast, cbs_msg_tvb, 0, len, "GSM Cell Broadcast Message"); cbs_msg_tree = proto_item_add_subtree(cbs_msg_item, ett_cbs_msg); - proto_tree_add_string(cbs_msg_tree, hf_gsm_cbs_message_content, cbs_msg_tvb, 0, len, tvb_get_string_enc(wmem_packet_scope(), cbs_msg_tvb, 0, len, ENC_ASCII)); + proto_tree_add_item(cbs_msg_tree, hf_gsm_cbs_message_content, cbs_msg_tvb, 0, len, ENC_ASCII|ENC_NA); } return tvb_captured_length(tvb); diff --git a/epan/dissectors/packet-cmpp.c b/epan/dissectors/packet-cmpp.c index 4d6687727a..125ea82727 100644 --- a/epan/dissectors/packet-cmpp.c +++ b/epan/dissectors/packet-cmpp.c @@ -251,13 +251,12 @@ static gint ett_deliver_report = -1; /* Helper functions */ -static char* +static const guint8* cmpp_octet_string(proto_tree *tree, tvbuff_t *tvb, gint field, gint offset, gint length) { - char *display; + const guint8 *display; - display = (char *)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII); - proto_tree_add_string(tree, field, tvb, offset, length, display); + proto_tree_add_item_ret_string(tree, field, tvb, offset, length, ENC_ASCII, wmem_packet_scope(), &display); return display; } diff --git a/epan/dissectors/packet-coap.c b/epan/dissectors/packet-coap.c index 8f02858c4b..f65691650e 100644 --- a/epan/dissectors/packet-coap.c +++ b/epan/dissectors/packet-coap.c @@ -347,11 +347,9 @@ dissect_coap_opt_uint(tvbuff_t *tvb, proto_item *head_item, proto_tree *subtree, static void dissect_coap_opt_uri_host(tvbuff_t *tvb, proto_item *head_item, proto_tree *subtree, gint offset, gint opt_length) { - guint8 *str; - - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, opt_length, ENC_ASCII); + const guint8 *str; - proto_tree_add_string(subtree, hf_coap_opt_uri_host, tvb, offset, opt_length, str); + proto_tree_add_item_ret_string(subtree, hf_coap_opt_uri_host, tvb, offset, opt_length, ENC_ASCII, wmem_packet_scope(), &str); /* add info to the head of the packet detail */ proto_item_append_text(head_item, ": %s", str); diff --git a/epan/dissectors/packet-collectd.c b/epan/dissectors/packet-collectd.c index 8be7a6d921..fafccdc63d 100644 --- a/epan/dissectors/packet-collectd.c +++ b/epan/dissectors/packet-collectd.c @@ -33,7 +33,7 @@ #include -#define STR_NONNULL(str) ((str) ? (str) : "(null)") +#define STR_NONNULL(str) ((str) ? ((gchar*)str) : "(null)") #define TYPE_HOST 0x0000 #define TYPE_TIME 0x0001 @@ -53,36 +53,36 @@ void proto_register_collectd(void); typedef struct value_data_s { - gchar *host; + const guint8 *host; gint host_off; gint host_len; guint64 time_value; gint time_off; guint64 interval; gint interval_off; - gchar *plugin; + const guint8 *plugin; gint plugin_off; gint plugin_len; - gchar *plugin_instance; + const guint8 *plugin_instance; gint plugin_instance_off; gint plugin_instance_len; - gchar *type; + const guint8 *type; gint type_off; gint type_len; - gchar *type_instance; + const guint8 *type_instance; gint type_instance_off; gint type_instance_len; } value_data_t; typedef struct notify_data_s { - gchar *host; + const guint8 *host; gint host_off; gint host_len; guint64 time_value; gint time_off; guint64 severity; gint severity_off; - gchar *message; + const guint8 *message; gint message_off; gint message_len; } notify_data_t; @@ -355,7 +355,7 @@ collectd_proto_tree_add_assembled_notification (tvbuff_t *tvb, static int dissect_collectd_string (tvbuff_t *tvb, packet_info *pinfo, gint type_hf, gint offset, gint *ret_offset, gint *ret_length, - gchar **ret_string, proto_tree *tree_root, + const guint8 **ret_string, proto_tree *tree_root, proto_item **ret_item) { proto_tree *pt; @@ -391,16 +391,15 @@ dissect_collectd_string (tvbuff_t *tvb, packet_info *pinfo, gint type_hf, *ret_offset = offset + 4; *ret_length = length - 4; - *ret_string = tvb_get_string_enc(wmem_packet_scope(), tvb, *ret_offset, *ret_length, ENC_ASCII); + proto_tree_add_uint (pt, hf_collectd_type, tvb, offset, 2, type); + proto_tree_add_uint (pt, hf_collectd_length, tvb, offset + 2, 2, length); + proto_tree_add_item_ret_string (pt, type_hf, tvb, *ret_offset, *ret_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), ret_string); + proto_item_append_text(pt, "\"%s\"", *ret_string); if (ret_item != NULL) *ret_item = pi; - proto_tree_add_uint (pt, hf_collectd_type, tvb, offset, 2, type); - proto_tree_add_uint (pt, hf_collectd_length, tvb, offset + 2, 2, length); - proto_tree_add_item (pt, type_hf, tvb, *ret_offset, *ret_length, ENC_ASCII|ENC_NA); - return (0); } /* int dissect_collectd_string */ @@ -917,7 +916,7 @@ dissect_collectd (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat gint offset; gint size; - gchar *pkt_host = NULL; + const guint8 *pkt_host = NULL; gint pkt_plugins = 0, pkt_values = 0, pkt_messages = 0, pkt_unknown = 0, pkt_errors = 0; value_data_t vdispatch; notify_data_t ndispatch; diff --git a/epan/dissectors/packet-dcerpc-epm.c b/epan/dissectors/packet-dcerpc-epm.c index efa83ae0ae..6789b51a17 100644 --- a/epan/dissectors/packet-dcerpc-epm.c +++ b/epan/dissectors/packet-dcerpc-epm.c @@ -157,7 +157,7 @@ epm_dissect_ept_entry_t(tvbuff_t *tvb, int offset, proto_tree *tree=NULL; int old_offset=offset; guint32 len; - const char *str; + const guint8 *str; if(di->conformant_run){ return offset; @@ -178,8 +178,7 @@ epm_dissect_ept_entry_t(tvbuff_t *tvb, int offset, hf_epm_ann_offset, NULL); offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_epm_ann_len, &len); - str=tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII); - proto_tree_add_item(tree, hf_epm_annotation, tvb, offset, len, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(tree, hf_epm_annotation, tvb, offset, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); offset += len; if(str&&str[0]){ @@ -315,6 +314,7 @@ epm_dissect_tower_data (tvbuff_t *tvb, int offset, guint16 num_floors, ii; const char *uuid_name; guint8 u8little_endian = DREP_LITTLE_ENDIAN; + const guint8 *str; if(di->conformant_run){ return offset; @@ -425,18 +425,18 @@ epm_dissect_tower_data (tvbuff_t *tvb, int offset, break; case PROTO_ID_NAMED_PIPES: /* \\PIPE\xxx named pipe */ - proto_tree_add_item(tr, hf_epm_proto_named_pipes, tvb, offset, len, ENC_ASCII|ENC_NA); - proto_item_append_text(tr, "NamedPipe:%s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII)); + proto_tree_add_item_ret_string(tr, hf_epm_proto_named_pipes, tvb, offset, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(tr, "NamedPipe:%s", str); break; case PROTO_ID_NAMED_PIPES_2: /* PIPENAME named pipe */ - proto_tree_add_item(tr, hf_epm_proto_named_pipes, tvb, offset, len, ENC_ASCII|ENC_NA); - proto_item_append_text(tr, "PIPE:%s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII)); + proto_tree_add_item_ret_string(tr, hf_epm_proto_named_pipes, tvb, offset, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(tr, "PIPE:%s", str); break; case PROTO_ID_NETBIOS: /* \\NETBIOS netbios name */ - proto_tree_add_item(tr, hf_epm_proto_netbios_name, tvb, offset, len, ENC_ASCII|ENC_NA); - proto_item_append_text(tr, "NetBIOS:%s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII)); + proto_tree_add_item_ret_string(tr, hf_epm_proto_netbios_name, tvb, offset, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(tr, "NetBIOS:%s", str); break; case PROTO_ID_HTTP: /* RPC over HTTP */ proto_tree_add_item(tr, hf_epm_proto_http_port, tvb, offset, 2, ENC_BIG_ENDIAN); diff --git a/epan/dissectors/packet-dcerpc-fileexp.c b/epan/dissectors/packet-dcerpc-fileexp.c index e398c2ce1d..5cc6c1e222 100644 --- a/epan/dissectors/packet-dcerpc-fileexp.c +++ b/epan/dissectors/packet-dcerpc-fileexp.c @@ -566,8 +566,7 @@ typedef [string] byte NameString_t[AFS_NAMEMAX]; col_append_fstr (pinfo->cinfo, COL_INFO, " String_size:%u", string_size); if (string_size < AFS_NAMEMAX) { - proto_tree_add_item (tree, hf_fileexp_afsNameString_t_principalName_string, tvb, offset, string_size, ENC_ASCII|ENC_NA); - namestring = tvb_get_string_enc (wmem_packet_scope(), tvb, offset, string_size, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_fileexp_afsNameString_t_principalName_string, tvb, offset, string_size, ENC_ASCII|ENC_NA, wmem_packet_scope(), &namestring); offset += string_size; col_append_fstr (pinfo->cinfo, COL_INFO, " Principal:%s", namestring); } diff --git a/epan/dissectors/packet-dcerpc-fldb.c b/epan/dissectors/packet-dcerpc-fldb.c index d56f60d9e9..eefb05b2f3 100644 --- a/epan/dissectors/packet-dcerpc-fldb.c +++ b/epan/dissectors/packet-dcerpc-fldb.c @@ -359,9 +359,8 @@ dissect_vlconf_cell (tvbuff_t *tvb, int offset, for (i = 0; i < MAXVLHOSTSPERCELL; i++) { - proto_tree_add_item (tree, hf_fldb_vlconf_cell_hostname, tvb, offset, - 64, ENC_ASCII|ENC_NA); - hostname = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 64, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_fldb_vlconf_cell_hostname, tvb, offset, + 64, ENC_ASCII|ENC_NA, wmem_packet_scope(), &hostname); offset += 64; /* some reason this 114 seems to be incorrect... cutting 4 short to compensate.... */ col_append_fstr (pinfo->cinfo, COL_INFO, " hostName: %s", hostname); } @@ -435,10 +434,8 @@ typedef [string] byte NameString_t[AFS_NAMEMAX]; if (string_size < AFS_NAMEMAX) { /* proto_tree_add_string(tree, id, tvb, start, length, value_ptr); */ - proto_tree_add_item (tree, - hf_fldb_afsNameString_t_principalName_string, - tvb, offset, string_size, ENC_ASCII|ENC_NA); - namestring = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, string_size, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_fldb_afsNameString_t_principalName_string, + tvb, offset, string_size, ENC_ASCII|ENC_NA, wmem_packet_scope(), &namestring); offset += string_size; col_append_fstr (pinfo->cinfo, COL_INFO, " Principal:%s", namestring); } @@ -632,8 +629,8 @@ dissect_vldbentry (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, dcerpc_info *di, guint8 *drep) { - proto_item *item = NULL; - proto_tree *tree = NULL; + proto_item *item; + proto_tree *tree; int old_offset = offset; const guint8 *volumename, *siteprincipal, *charspares, *lockername; guint32 volumetype, nservers, sitepartition, sitemaxreplicalatency; @@ -647,16 +644,12 @@ dissect_vldbentry (tvbuff_t *tvb, int offset, #define MAXVOLTYPES 8 #define MAXLOCKNAMELEN 64 - if (parent_tree) - { - tree = proto_tree_add_subtree (parent_tree, tvb, offset, -1, ett_fldb_vldbentry, &item, "vldbentry:"); - } + tree = proto_tree_add_subtree (parent_tree, tvb, offset, -1, ett_fldb_vldbentry, &item, "vldbentry:"); /* byte name[114]; Volume name */ - proto_tree_add_item (tree, hf_fldb_vldbentry_volumename, tvb, offset, 114, - ENC_ASCII|ENC_NA); - volumename = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 114, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_fldb_vldbentry_volumename, tvb, offset, 114, + ENC_ASCII|ENC_NA, wmem_packet_scope(), &volumename); offset += 110; /* some reason this 114 seems to be incorrect... cutting 4 short to compensate.... */ col_append_fstr (pinfo->cinfo, COL_INFO, " Name: %s", volumename); @@ -715,9 +708,8 @@ dissect_vldbentry (tvbuff_t *tvb, int offset, /* kerb_princ_name sitePrincipal[MAXNSERVERS]; principal */ for (i = 0; i < MAXNSERVERS; i++) { - proto_tree_add_item (tree, hf_fldb_vldbentry_siteprincipal, tvb, - offset, 64, ENC_ASCII|ENC_NA); - siteprincipal = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 64, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_fldb_vldbentry_siteprincipal, tvb, + offset, 64, ENC_ASCII|ENC_NA, wmem_packet_scope(), &siteprincipal); offset += 64; col_append_fstr (pinfo->cinfo, COL_INFO, " Princ: %s", siteprincipal); } @@ -853,31 +845,27 @@ dissect_vldbentry (tvbuff_t *tvb, int offset, col_append_fstr (pinfo->cinfo, COL_INFO, " spare2:%u", spare2); /* unsigned32 spare3; */ - offset = - dissect_ndr_uint32 (tvb, offset, pinfo, tree, di, drep, + offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, di, drep, hf_fldb_vldbentry_spare3, &spare3); col_append_fstr (pinfo->cinfo, COL_INFO, " spare3:%u", spare3); /* unsigned32 spare4; */ - offset = - dissect_ndr_uint32 (tvb, offset, pinfo, tree, di, drep, + offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, di, drep, hf_fldb_vldbentry_spare4, &spare4); - col_append_fstr (pinfo->cinfo, COL_INFO, " spare4:%u", spare4); + col_append_fstr (pinfo->cinfo, COL_INFO, " spare4:%u", spare4); /* byte LockerName[MAXLOCKNAMELEN]; */ - proto_tree_add_item (tree, hf_fldb_vldbentry_lockername, tvb, offset, - MAXLOCKNAMELEN, ENC_ASCII|ENC_NA); - lockername = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, MAXLOCKNAMELEN, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_fldb_vldbentry_lockername, tvb, offset, + MAXLOCKNAMELEN, ENC_ASCII|ENC_NA, wmem_packet_scope(), &lockername); offset += MAXLOCKNAMELEN; /* some reason this 114 seems to be incorrect... cutting 4 short to compensate.... */ - col_append_fstr (pinfo->cinfo, COL_INFO, " LockerName: %s", lockername); + col_append_fstr (pinfo->cinfo, COL_INFO, " LockerName: %s", lockername); /* byte charSpares[50]; */ - proto_tree_add_item (tree, hf_fldb_vldbentry_charspares, tvb, offset, 50, - ENC_ASCII|ENC_NA); - charspares = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 50, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_fldb_vldbentry_charspares, tvb, offset, 50, + ENC_ASCII|ENC_NA, wmem_packet_scope(), &charspares); offset += 50; /* some reason this 114 seems to be incorrect... cutting 4 short to compensate.... */ - col_append_fstr (pinfo->cinfo, COL_INFO, " charSpares:%s", charspares); + col_append_fstr (pinfo->cinfo, COL_INFO, " charSpares:%s", charspares); proto_item_set_len (item, offset - old_offset); @@ -1007,8 +995,7 @@ fldb_dissect_getsiteinfo_resp (tvbuff_t *tvb, int offset, offset += 48; /* part of kerbprin before name... */ - proto_tree_add_item (tree, hf_fldb_namestring, tvb, offset, 64, ENC_ASCII|ENC_NA); - namestring = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 64, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_fldb_namestring, tvb, offset, 64, ENC_ASCII|ENC_NA, wmem_packet_scope(), &namestring); offset += 64; col_append_fstr (pinfo->cinfo, COL_INFO, " %s", namestring); diff --git a/epan/dissectors/packet-dcerpc-rpriv.c b/epan/dissectors/packet-dcerpc-rpriv.c index 6c7f0d9e27..9065425f82 100644 --- a/epan/dissectors/packet-dcerpc-rpriv.c +++ b/epan/dissectors/packet-dcerpc-rpriv.c @@ -65,8 +65,8 @@ rpriv_dissect_get_eptgt_rqst (tvbuff_t *tvb, int offset, */ guint32 authn_svc, authz_svc, key_size, key_size2, var1; - const char *key_t1 = NULL; - const char *key_t2 = NULL; + const guint8 *key_t1 = NULL; + const guint8 *key_t2 = NULL; offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_rpriv_get_eptgt_rqst_authn_svc, &authn_svc); offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_rpriv_get_eptgt_rqst_authz_svc, &authz_svc); @@ -75,14 +75,12 @@ rpriv_dissect_get_eptgt_rqst (tvbuff_t *tvb, int offset, offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_rpriv_get_eptgt_rqst_key_size2, &key_size); /* advance to get size of cell, and princ */ - proto_tree_add_item (tree, hf_rpriv_get_eptgt_rqst_key_t, tvb, offset, key_size, ENC_ASCII|ENC_NA); - key_t1 = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, key_size, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_rpriv_get_eptgt_rqst_key_t, tvb, offset, key_size, ENC_ASCII|ENC_NA, wmem_packet_scope(), &key_t1); offset += key_size; offset += 8; offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_rpriv_get_eptgt_rqst_key_size2, &key_size2); - proto_tree_add_item (tree, hf_rpriv_get_eptgt_rqst_key_t2, tvb, offset, key_size2, ENC_ASCII|ENC_NA); - key_t2 = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, key_size2, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_rpriv_get_eptgt_rqst_key_t2, tvb, offset, key_size2, ENC_ASCII|ENC_NA, wmem_packet_scope(), &key_t2); offset += key_size2; diff --git a/epan/dissectors/packet-dcerpc-rs_acct.c b/epan/dissectors/packet-dcerpc-rs_acct.c index 24d1f92688..f9c2d4591c 100644 --- a/epan/dissectors/packet-dcerpc-rs_acct.c +++ b/epan/dissectors/packet-dcerpc-rs_acct.c @@ -56,7 +56,7 @@ rs_acct_dissect_lookup_rqst (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep) { guint32 key_size; - const char *keyx_t = NULL; + const guint8 *keyx_t = NULL; offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_rs_acct_lookup_rqst_var, NULL); @@ -64,8 +64,7 @@ rs_acct_dissect_lookup_rqst (tvbuff_t *tvb, int offset, hf_rs_acct_lookup_rqst_key_size, &key_size); if (key_size){ /* Not able to yet decipher the OTHER versions of this call just yet. */ - proto_tree_add_item (tree, hf_rs_acct_lookup_rqst_key_t, tvb, offset, key_size, ENC_ASCII|ENC_NA); - keyx_t = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, key_size, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_rs_acct_lookup_rqst_key_t, tvb, offset, key_size, ENC_ASCII|ENC_NA, wmem_packet_scope(), &keyx_t); offset += key_size; col_append_fstr(pinfo->cinfo, COL_INFO, @@ -85,16 +84,15 @@ rs_acct_dissect_get_projlist_rqst (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, dcerpc_info *di, guint8 *drep) { guint32 key_size; - const char *keyx_t = NULL; + const guint8 *keyx_t = NULL; offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_rs_acct_get_projlist_rqst_var1, NULL); offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_rs_acct_get_projlist_rqst_key_size, &key_size); - proto_tree_add_item (tree, hf_rs_acct_get_projlist_rqst_key_t, - tvb, offset, key_size, ENC_ASCII|ENC_NA); - keyx_t = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, key_size, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_rs_acct_get_projlist_rqst_key_t, + tvb, offset, key_size, ENC_ASCII|ENC_NA, wmem_packet_scope(), &keyx_t); offset += key_size; col_append_fstr(pinfo->cinfo, COL_INFO, diff --git a/epan/dissectors/packet-dcerpc-rs_misc.c b/epan/dissectors/packet-dcerpc-rs_misc.c index de5952d946..f45fb9d182 100644 --- a/epan/dissectors/packet-dcerpc-rs_misc.c +++ b/epan/dissectors/packet-dcerpc-rs_misc.c @@ -53,7 +53,7 @@ rs_misc_dissect_login_get_info_rqst (tvbuff_t *tvb, int offset, { guint32 key_size; - const char *key_t1 = NULL; + const guint8 *key_t1 = NULL; offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, di, drep, hf_rs_misc_login_get_info_rqst_var, NULL); @@ -62,8 +62,7 @@ rs_misc_dissect_login_get_info_rqst (tvbuff_t *tvb, int offset, if (key_size){ /* Not able to yet decipher the OTHER versions of this call just yet. */ - proto_tree_add_item (tree, hf_rs_misc_login_get_info_rqst_key_t, tvb, offset, key_size, ENC_ASCII|ENC_NA); - key_t1 = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, key_size, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_rs_misc_login_get_info_rqst_key_t, tvb, offset, key_size, ENC_ASCII|ENC_NA, wmem_packet_scope(), &key_t1); offset += key_size; col_append_fstr(pinfo->cinfo, COL_INFO, diff --git a/epan/dissectors/packet-dcerpc-rs_pgo.c b/epan/dissectors/packet-dcerpc-rs_pgo.c index a179df707a..d07f45da26 100644 --- a/epan/dissectors/packet-dcerpc-rs_pgo.c +++ b/epan/dissectors/packet-dcerpc-rs_pgo.c @@ -161,9 +161,10 @@ dissect_sec_rgy_pname_t (tvbuff_t * tvb, int offset, { - proto_item *item = NULL; - proto_tree *tree = NULL; + proto_item *item; + proto_tree *tree; int old_offset = offset; + const guint8 *principal; #define sec_rgy_pname_t_size 257 /* dissect sec_rgy_pname const signed32 sec_rgy_pname_t_size = 257; * Include final '\0' * @@ -177,11 +178,7 @@ dissect sec_rgy_pname const signed32 sec_rgy_pname_t_size = 257; * In } - if (parent_tree) - { - tree = - proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_sec_rgy_pname_t, &item, "sec_rgy_pname_t"); - } + tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_sec_rgy_pname_t, &item, "sec_rgy_pname_t"); offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, di, drep, hf_sec_rgy_pname_t_size, &string_size); @@ -190,12 +187,11 @@ dissect sec_rgy_pname const signed32 sec_rgy_pname_t_size = 257; * In { /* proto_tree_add_string(tree, id, tvb, start, length, value_ptr); */ - proto_tree_add_item (tree, hf_sec_rgy_pname_t_principalName_string, - tvb, offset, string_size, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(tree, hf_sec_rgy_pname_t_principalName_string, + tvb, offset, string_size, ENC_ASCII|ENC_NA, wmem_packet_scope(), &principal); if (string_size > 1) { - col_append_fstr (pinfo->cinfo, COL_INFO, " Principal:%s", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset, string_size, ENC_ASCII)); + col_append_fstr (pinfo->cinfo, COL_INFO, " Principal:%s", principal); } offset += string_size; } @@ -372,9 +368,10 @@ dissect_sec_rgy_name_t (tvbuff_t * tvb, int offset, { - proto_item *item = NULL; - proto_tree *tree = NULL; + proto_item *item; + proto_tree *tree; int old_offset = offset; + const guint8 *principal; #define sec_rgy_name_t_size 1025 /* typedef [string] char sec_rgy_name_t[sec_rgy_name_t_size]; */ guint32 string_size; @@ -385,11 +382,7 @@ dissect_sec_rgy_name_t (tvbuff_t * tvb, int offset, } - if (parent_tree) - { - tree = - proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_sec_rgy_name_t, &item, "sec_rgy_name_t"); - } + tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_sec_rgy_name_t, &item, "sec_rgy_name_t"); offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, @@ -399,12 +392,11 @@ dissect_sec_rgy_name_t (tvbuff_t * tvb, int offset, { /* proto_tree_add_string(tree, id, tvb, start, length, value_ptr); */ - proto_tree_add_item (tree, hf_sec_rgy_name_t_principalName_string, - tvb, offset, string_size, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(tree, hf_sec_rgy_name_t_principalName_string, + tvb, offset, string_size, ENC_ASCII|ENC_NA, wmem_packet_scope(), &principal); if (string_size > 1) { - col_append_fstr (pinfo->cinfo, COL_INFO, " Principal:%s", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset, string_size, ENC_ASCII)); + col_append_fstr (pinfo->cinfo, COL_INFO, " Principal:%s", principal); } offset += string_size; } diff --git a/epan/dissectors/packet-dcerpc-spoolss.c b/epan/dissectors/packet-dcerpc-spoolss.c index 8365817769..c44db46d51 100644 --- a/epan/dissectors/packet-dcerpc-spoolss.c +++ b/epan/dissectors/packet-dcerpc-spoolss.c @@ -708,18 +708,16 @@ dissect_printerdata_data(tvbuff_t *tvb, int offset, switch(type) { case DCERPC_REG_SZ: { - char *data = tvb_get_string_enc(wmem_packet_scope(), tvb, offset - size, size, ENC_UTF_16|ENC_LITTLE_ENDIAN); + const guint8 *data; - proto_item_append_text(item, ": %s", data); - - col_append_fstr( - pinfo->cinfo, COL_INFO, " = %s", data); - - hidden_item = proto_tree_add_string( + hidden_item = proto_tree_add_item_ret_string( tree, hf_printerdata_data_sz, tvb, - offset - size, size, data); + offset - size, size, ENC_UTF_16|ENC_LITTLE_ENDIAN, wmem_packet_scope(), &data); PROTO_ITEM_SET_HIDDEN(hidden_item); + proto_item_append_text(item, ": %s", data); + + col_append_fstr(pinfo->cinfo, COL_INFO, " = %s", data); break; } case DCERPC_REG_DWORD: { diff --git a/epan/dissectors/packet-dcp-etsi.c b/epan/dissectors/packet-dcp-etsi.c index 7a97b0d76b..35acba77a7 100644 --- a/epan/dissectors/packet-dcp-etsi.c +++ b/epan/dissectors/packet-dcp-etsi.c @@ -153,7 +153,8 @@ static gboolean dissect_dcp_etsi (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void * data _U_) { guint8 *sync; - proto_tree *dcp_tree = NULL; + proto_tree *dcp_tree; + proto_item *ti; guint16 word; /* 6.1 AF packet structure @@ -196,11 +197,8 @@ dissect_dcp_etsi (tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, void * col_set_str (pinfo->cinfo, COL_PROTOCOL, "DCP (ETSI)"); /*col_append_fstr (pinfo->cinfo, COL_INFO, " tvb %d", tvb_length(tvb));*/ - if(tree) { - proto_item *ti = NULL; - ti = proto_tree_add_item (tree, proto_dcp_etsi, tvb, 0, -1, ENC_NA); - dcp_tree = proto_item_add_subtree (ti, ett_edcp); - } + ti = proto_tree_add_item (tree, proto_dcp_etsi, tvb, 0, -1, ENC_NA); + dcp_tree = proto_item_add_subtree (ti, ett_edcp); sync = tvb_get_string_enc(wmem_packet_scope(), tvb, 0, 2, ENC_ASCII); dissector_try_string(dcp_dissector_table, (char*)sync, tvb, pinfo, dcp_tree, NULL); diff --git a/epan/dissectors/packet-dhcp-failover.c b/epan/dissectors/packet-dhcp-failover.c index aacffcfee4..1146df9c59 100644 --- a/epan/dissectors/packet-dhcp-failover.c +++ b/epan/dissectors/packet-dhcp-failover.c @@ -376,7 +376,7 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* da gboolean bogus_poffset; guint16 opcode, option_length; guint8 htype, reject_reason, message_digest_type, binding_status; - guint8 *vendor_class_str; + const guint8 *vendor_class_str; const gchar *htype_str; gchar *lease_expiration_time_str, *grace_expiration_time_str, *potential_expiration_time_str, *client_last_transaction_time_str, *start_time_of_state_str; @@ -563,15 +563,18 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* da break; case DHCP_FO_PD_CLIENT_IDENTIFIER: + { + const guint8* identifier; /* * XXX - if this is truly like DHCP option 81, * we need to dissect it as such. */ - proto_item_append_text(oi,", \"%s\"", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, option_length, ENC_ASCII)); - - proto_tree_add_item(option_tree, + proto_tree_add_item_ret_string(option_tree, hf_dhcpfo_client_identifier, tvb, offset, - option_length, ENC_ASCII|ENC_NA); + option_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &identifier); + + proto_item_append_text(oi,", \"%s\"", identifier); + } break; case DHCP_FO_PD_CLIENT_HARDWARE_ADDRESS: @@ -631,13 +634,11 @@ dissect_dhcpfo_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* da break; case DHCP_FO_PD_VENDOR_CLASS: - vendor_class_str = - tvb_get_string_enc(wmem_packet_scope(), tvb, offset, option_length, ENC_ASCII); + proto_tree_add_item_ret_string(option_tree, + hf_dhcpfo_vendor_class, tvb, offset, + option_length, ENC_ASCII, wmem_packet_scope(), &vendor_class_str); proto_item_append_text(oi,", \"%s\"", format_text(vendor_class_str, option_length)); - proto_tree_add_string(option_tree, - hf_dhcpfo_vendor_class, tvb, offset, - option_length, vendor_class_str); break; case DHCP_FO_PD_LEASE_EXPIRATION_TIME: diff --git a/epan/dissectors/packet-diameter_3gpp.c b/epan/dissectors/packet-diameter_3gpp.c index abe7f0bb39..ed75893ee4 100644 --- a/epan/dissectors/packet-diameter_3gpp.c +++ b/epan/dissectors/packet-diameter_3gpp.c @@ -343,9 +343,9 @@ dissect_diameter_3gpp_imeisv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree * if (!g_ascii_isprint(tvb_get_guint8(tvb, i))) return length; - item = proto_tree_add_item(tree, hf_diameter_3gpp_imeisv, tvb, offset, length, ENC_UTF_8 | ENC_NA); + item = proto_tree_add_item_ret_string(tree, hf_diameter_3gpp_imeisv, tvb, offset, length, + ENC_UTF_8 | ENC_NA, wmem_packet_scope(), (const guint8**)&diam_sub_dis->avp_str); PROTO_ITEM_SET_GENERATED(item); - diam_sub_dis->avp_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8 | ENC_NA); } return length; @@ -449,9 +449,9 @@ dissect_diameter_3gpp_af_application_identifier(tvbuff_t *tvb, packet_info *pinf if (!g_ascii_isprint(tvb_get_guint8(tvb, i))) return length; - item = proto_tree_add_item(tree, hf_diameter_3gpp_af_application_identifier, tvb, offset, length, ENC_UTF_8 | ENC_NA); + item = proto_tree_add_item_ret_string(tree, hf_diameter_3gpp_af_application_identifier, tvb, offset, length, + ENC_UTF_8 | ENC_NA, wmem_packet_scope(), (const guint8**)&diam_sub_dis->avp_str); PROTO_ITEM_SET_GENERATED(item); - diam_sub_dis->avp_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8 | ENC_NA); } return length; @@ -474,9 +474,9 @@ dissect_diameter_3gpp_af_charging_identifier(tvbuff_t *tvb, packet_info *pinfo _ if (!g_ascii_isprint(tvb_get_guint8(tvb, i))) return length; - item = proto_tree_add_item(tree, hf_diameter_3gpp_af_charging_identifier, tvb, offset, length, ENC_UTF_8 | ENC_NA); + item = proto_tree_add_item_ret_string(tree, hf_diameter_3gpp_af_charging_identifier, tvb, offset, length, + ENC_UTF_8 | ENC_NA, wmem_packet_scope(), (const guint8**)&diam_sub_dis->avp_str); PROTO_ITEM_SET_GENERATED(item); - diam_sub_dis->avp_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8 | ENC_NA); } return length; @@ -1069,9 +1069,9 @@ dissect_diameter_3gpp_charging_rule_name(tvbuff_t *tvb, packet_info *pinfo _U_, if (!g_ascii_isprint(tvb_get_guint8(tvb, i))) return length; - item = proto_tree_add_item(tree, hf_diameter_3gpp_charging_rule_name, tvb, offset, length, ENC_UTF_8 | ENC_NA); + item = proto_tree_add_item_ret_string(tree, hf_diameter_3gpp_charging_rule_name, tvb, offset, length, + ENC_UTF_8 | ENC_NA, wmem_packet_scope(), (const guint8**)&diam_sub_dis->avp_str); PROTO_ITEM_SET_GENERATED(item); - diam_sub_dis->avp_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_UTF_8 | ENC_NA); } return length; diff --git a/epan/dissectors/packet-dis.c b/epan/dissectors/packet-dis.c index 115d0e5951..d0cd27883a 100644 --- a/epan/dissectors/packet-dis.c +++ b/epan/dissectors/packet-dis.c @@ -5110,7 +5110,7 @@ static int dissect_DIS_PARSER_ENTITY_STATE_PDU(tvbuff_t *tvb, packet_info *pinfo proto_tree *sub_tree2; guint8 variableParameterType, numVariable, entity_marking_character_set; guint32 i; - char *entity_marking_text; + const guint8 *entity_marking_text; entitySite = tvb_get_ntohs(tvb, offset); entityApplication = tvb_get_ntohs(tvb, offset+2); @@ -5249,14 +5249,13 @@ static int dissect_DIS_PARSER_ENTITY_STATE_PDU(tvbuff_t *tvb, packet_info *pinfo entity_marking_character_set = tvb_get_guint8(tvb, offset); proto_tree_add_uint(sub_tree, hf_dis_entity_marking_character_set, tvb, offset, 1, entity_marking_character_set); offset += 1; - entity_marking_text = tvb_get_string_enc(wmem_packet_scope(), tvb, offset , 11, ENC_ASCII); switch (entity_marking_character_set) { case 0:/* Unused */ break;/* Don't translate it, nothing to be translated */ case 1:/* ASCII */ + proto_tree_add_item_ret_string(sub_tree, hf_dis_entity_marking, tvb, offset, 11, ENC_ASCII|ENC_NA, wmem_packet_scope(), &entity_marking_text); col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", entity_marking_text); - proto_tree_add_item(sub_tree, hf_dis_entity_marking, tvb, offset, 11, ENC_ASCII|ENC_NA); case 2:/* Army Marking (CCTT) */ /* TODO: Complete this */ break; @@ -6235,7 +6234,7 @@ static int dissect_DIS_PARSER_AGGREGATE_STATE_PDU(tvbuff_t *tvb, packet_info *pi { guint32 number_of_variable_datum_records; proto_tree *sub_tree; - char *marking_text; + const guint8 *marking_text; static guint32 entitySite, entityApplication, entityEntity; guint16 number_of_aggregates, number_of_entities, number_of_silent_aggregates_types, padding; int i; @@ -6262,9 +6261,8 @@ static int dissect_DIS_PARSER_AGGREGATE_STATE_PDU(tvbuff_t *tvb, packet_info *pi sub_tree = proto_tree_add_subtree(tree, tvb, offset, 12, ett_aggregate_marking_text, NULL, "Aggregate Marking"); proto_tree_add_item(sub_tree, hf_dis_aggregate_marking_character_set, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; - marking_text = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 31, ENC_ASCII); + proto_tree_add_item_ret_string(sub_tree, hf_dis_aggregate_marking, tvb, offset, 31, ENC_ASCII|ENC_NA, wmem_packet_scope(), &marking_text); col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", marking_text); - proto_tree_add_item(sub_tree, hf_dis_aggregate_marking, tvb, offset, 31, ENC_ASCII|ENC_NA); offset += 31; sub_tree = proto_tree_add_subtree(tree, tvb, offset, 12, ett_aggregate_dimensions, NULL, "Dimensions"); diff --git a/epan/dissectors/packet-dmp.c b/epan/dissectors/packet-dmp.c index a9dea7554b..aa19f85d36 100644 --- a/epan/dissectors/packet-dmp.c +++ b/epan/dissectors/packet-dmp.c @@ -533,7 +533,7 @@ static struct dmp_data { gint prec; gint body_format; gint notif_type; - guchar *struct_id; + const guint8 *struct_id; gint32 subm_time; guint8 msg_id_type; guint8 mts_id_length; @@ -3100,8 +3100,7 @@ static void dissect_dmp_structured_id (tvbuff_t *tvb, proto_tree *body_tree, break; case STRUCT_ID_STRING: - dmp.struct_id = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, (gint) dmp_struct_length, ENC_ASCII); - proto_tree_add_item (body_tree, hf_message_bodyid_string, tvb, offset, dmp_struct_length, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(body_tree, hf_message_bodyid_string, tvb, offset, dmp_struct_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &dmp.struct_id); break; case STRUCT_ID_ZSTRING: diff --git a/epan/dissectors/packet-dnp.c b/epan/dissectors/packet-dnp.c index dac30fed13..3bb16ca653 100644 --- a/epan/dissectors/packet-dnp.c +++ b/epan/dissectors/packet-dnp.c @@ -1932,18 +1932,19 @@ dnp3_al_process_object(tvbuff_t *tvb, packet_info *pinfo, int offset, case AL_OBJ_DA_CONF: /* Device Attributes - DNP Subset and Conformance (Obj:00, Var:249) */ case AL_OBJ_DA_PROD: /* Device Attributes - Device Product Name and Model (Obj:00, Var:250) */ case AL_OBJ_DA_MFG: /* Device Attributes - Device Manufacturers Name (Obj:00, Var:252) */ - + { + const guint8* da_value; proto_tree_add_item(point_tree, hf_dnp3_al_datatype, tvb, offset, 1, ENC_LITTLE_ENDIAN); da_len = tvb_get_guint8(tvb, offset+1); proto_tree_add_item(point_tree, hf_dnp3_al_da_length, tvb, offset+1, 1, ENC_LITTLE_ENDIAN); - proto_tree_add_item(point_tree, hf_dnp3_al_da_value, tvb, offset+2, da_len, ENC_ASCII|ENC_NA); - proto_item_append_text(object_item, ", Value: %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset+2, da_len, ENC_ASCII)); + proto_tree_add_item_ret_string(point_tree, hf_dnp3_al_da_value, tvb, offset+2, da_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &da_value); + proto_item_append_text(object_item, ", Value: %s", da_value); offset += 2 + da_len; break; - + } /* Bit-based Data objects here */ case AL_OBJ_BI_1BIT: /* Single-Bit Binary Input (Obj:01, Var:01) */ case AL_OBJ_BO: /* Binary Output (Obj:10, Var:01) */ diff --git a/epan/dissectors/packet-dns.c b/epan/dissectors/packet-dns.c index 8f217ae4fc..016772b0ac 100644 --- a/epan/dissectors/packet-dns.c +++ b/epan/dissectors/packet-dns.c @@ -2501,7 +2501,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset, int offset = cur_offset; guint16 order; guint16 preference; - gchar *flags; + const guint8 *flags; guint8 flags_len; guint8 service_len; guint8 regex_len; @@ -2523,8 +2523,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset, proto_tree_add_item(rr_tree, hf_dns_naptr_flags_length, tvb, offset, 1, ENC_BIG_ENDIAN); flags_len = tvb_get_guint8(tvb, offset); offset += 1; - proto_tree_add_item(rr_tree, hf_dns_naptr_flags, tvb, offset, flags_len, ENC_ASCII|ENC_NA); - flags = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, flags_len, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(rr_tree, hf_dns_naptr_flags, tvb, offset, flags_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &flags); offset += flags_len; /* Service */ diff --git a/epan/dissectors/packet-dtn.c b/epan/dissectors/packet-dtn.c index 1ad920075c..b319ff12f2 100644 --- a/epan/dissectors/packet-dtn.c +++ b/epan/dissectors/packet-dtn.c @@ -1613,7 +1613,7 @@ display_extension_block(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int case BUNDLE_BLOCK_TYPE_CUSTODY_TRANSFER: { int custody_id; - const char *cteb_creator_custodian_eid; + const guint8 *cteb_creator_custodian_eid; int cteb_creator_custodian_eid_length; /* check requirements for Block Processing Control Flags */ @@ -1631,9 +1631,8 @@ display_extension_block(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int /* and second is the creator custodian EID */ cteb_creator_custodian_eid_length = block_length - sdnv_length; - cteb_creator_custodian_eid = (char *) tvb_get_string_enc(wmem_packet_scope(), tvb, offset, cteb_creator_custodian_eid_length, ENC_ASCII); - ti = proto_tree_add_string(block_tree, hf_block_control_block_cteb_creator_custodian_eid, tvb, offset, - cteb_creator_custodian_eid_length, cteb_creator_custodian_eid); + ti = proto_tree_add_item_ret_string(block_tree, hf_block_control_block_cteb_creator_custodian_eid, tvb, offset, + cteb_creator_custodian_eid_length, ENC_ASCII, wmem_packet_scope(), &cteb_creator_custodian_eid); /* also check if CTEB is valid, i.e. custodians match */ if (bundle_custodian == NULL) { diff --git a/epan/dissectors/packet-dvbci.c b/epan/dissectors/packet-dvbci.c index f63186a4cc..ead0db06e2 100644 --- a/epan/dissectors/packet-dvbci.c +++ b/epan/dissectors/packet-dvbci.c @@ -2742,7 +2742,7 @@ dissect_dvbci_payload_ap(guint32 tag, gint len_field _U_, guint8 menu_str_len; guint enc_len; dvb_encoding_e encoding; - guint8 *menu_string; + const guint8 *menu_string; guint8 data_rate; if (tag==T_APP_INFO) { @@ -2765,13 +2765,11 @@ dissect_dvbci_payload_ap(guint32 tag, gint len_field _U_, tree, hf_dvbci_ap_char_tbl, tvb, offset, enc_len, encoding); offset += enc_len; menu_str_len -= enc_len; - menu_string = tvb_get_string_enc(wmem_packet_scope(), - tvb, offset, menu_str_len, dvb_enc_to_item_enc(encoding)); + proto_tree_add_item_ret_string(tree, hf_dvbci_menu_str, + tvb, offset, menu_str_len, dvb_enc_to_item_enc(encoding), + wmem_packet_scope(), &menu_string); col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "Module name %s", menu_string); - proto_tree_add_string_format(tree, hf_dvbci_menu_str, - tvb, offset, menu_str_len, menu_string, - "Menu string: %s", menu_string); } } else if (tag== T_DATARATE_INFO) { @@ -3703,10 +3701,10 @@ dissect_dvbci_payload_ami(guint32 tag, gint len_field _U_, packet_info *pinfo, proto_tree *tree) { guint8 app_dom_id_len, init_obj_len; - guint8 *app_dom_id; + const guint8 *app_dom_id; guint8 ack_code; guint8 req_type; - guint8 *req_str; + const guint8 *req_str; switch(tag) { case T_REQUEST_START: @@ -3719,9 +3717,8 @@ dissect_dvbci_payload_ami(guint32 tag, gint len_field _U_, proto_tree_add_item(tree, hf_dvbci_init_obj_len, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; - proto_tree_add_item(tree, hf_dvbci_app_dom_id, - tvb, offset, app_dom_id_len, ENC_ASCII|ENC_NA); - app_dom_id = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, app_dom_id_len, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_dvbci_app_dom_id, + tvb, offset, app_dom_id_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &app_dom_id); if (app_dom_id) { col_append_sep_fstr(pinfo->cinfo, COL_INFO, " ", "for %s", app_dom_id); @@ -3751,14 +3748,10 @@ dissect_dvbci_payload_ami(guint32 tag, gint len_field _U_, if (tvb_reported_length_remaining(tvb, offset) <= 0) break; if (req_type==REQ_TYPE_FILE || req_type==REQ_TYPE_FILE_HASH) { - req_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, - tvb_reported_length_remaining(tvb, offset), ENC_ASCII); - if (!req_str) - break; - col_append_sep_fstr(pinfo->cinfo, COL_INFO, " ", "%s", req_str); - proto_tree_add_string_format_value(tree, hf_dvbci_file_name, + proto_tree_add_item_ret_string(tree, hf_dvbci_file_name, tvb, offset, tvb_reported_length_remaining(tvb, offset), - req_str, "%s", req_str); + ENC_ASCII, wmem_packet_scope(), &req_str); + col_append_sep_fstr(pinfo->cinfo, COL_INFO, " ", "%s", req_str); } else if (req_type==REQ_TYPE_DATA) { proto_tree_add_item(tree, hf_dvbci_ami_priv_data, tvb, offset, diff --git a/epan/dissectors/packet-edonkey.c b/epan/dissectors/packet-edonkey.c index b82b098b84..94499b2408 100644 --- a/epan/dissectors/packet-edonkey.c +++ b/epan/dissectors/packet-edonkey.c @@ -1133,16 +1133,15 @@ static int dissect_kademlia_tag_bsob(tvbuff_t *tvb, packet_info *pinfo _U_, static int dissect_kademlia_tag_string(tvbuff_t *tvb, packet_info *pinfo _U_, - int offset, proto_tree *tree, const gchar** string_value) + int offset, proto_tree *tree, const guint8** string_value) { proto_item *hidden_item; guint16 string_length = tvb_get_letohs(tvb, offset); hidden_item = proto_tree_add_uint(tree, hf_edonkey_string_length, tvb, offset, 2, string_length); PROTO_ITEM_SET_HIDDEN(hidden_item); - hidden_item = proto_tree_add_item(tree, hf_edonkey_string, tvb, offset + 2, string_length, ENC_ASCII|ENC_NA); + hidden_item = proto_tree_add_item_ret_string(tree, hf_edonkey_string, tvb, offset + 2, string_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), string_value); PROTO_ITEM_SET_HIDDEN(hidden_item); - *string_value = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 2, string_length, ENC_ASCII|ENC_NA); proto_tree_add_item(tree, hf_kademlia_tag_string, tvb, offset + 2, string_length, ENC_ASCII|ENC_NA); return offset + 2 + string_length; @@ -2371,7 +2370,7 @@ static int dissect_kademlia_tag(tvbuff_t *tvb, packet_info *pinfo, break; case KADEMLIA_TAGTYPE_STRING: { - const gchar* value; + const guint8* value; offset = dissect_kademlia_tag_string( tvb, pinfo, offset, subtree, &value ); proto_item_append_text( tag_node, "\"%s\"", value ); diff --git a/epan/dissectors/packet-epmd.c b/epan/dissectors/packet-epmd.c index f3532ac1fd..996987db11 100644 --- a/epan/dissectors/packet-epmd.c +++ b/epan/dissectors/packet-epmd.c @@ -119,9 +119,9 @@ const value_string epmd_version_vals[] = { static void dissect_epmd_request(packet_info *pinfo, tvbuff_t *tvb, gint offset, proto_tree *tree) { - guint8 type; - guint16 name_length = 0; - const gchar *name = NULL; + guint8 type; + guint16 name_length = 0; + const guint8 *name = NULL; proto_tree_add_item(tree, hf_epmd_len, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; @@ -144,8 +144,7 @@ dissect_epmd_request(packet_info *pinfo, tvbuff_t *tvb, gint offset, proto_tree offset += 2; name_length = tvb_get_ntohs(tvb, offset); proto_tree_add_item(tree, hf_epmd_name_len, tvb, offset, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tree, hf_epmd_name, tvb, offset + 2, name_length, ENC_ASCII|ENC_NA); - name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 2, name_length, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_epmd_name, tvb, offset + 2, name_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &name); offset += 2 + name_length; if (tvb_reported_length_remaining(tvb, offset) >= 2) { guint16 elen=0; @@ -160,16 +159,14 @@ dissect_epmd_request(packet_info *pinfo, tvbuff_t *tvb, gint offset, proto_tree case EPMD_PORT_REQ: case EPMD_PORT2_REQ: name_length = tvb_captured_length_remaining(tvb, offset); - proto_tree_add_item(tree, hf_epmd_name, tvb, offset, name_length, ENC_ASCII|ENC_NA); - name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, name_length, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_epmd_name, tvb, offset, name_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &name); break; case EPMD_ALIVE_REQ: proto_tree_add_item(tree, hf_epmd_port_no, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; name_length = tvb_captured_length_remaining(tvb, offset); - proto_tree_add_item(tree, hf_epmd_name, tvb, offset, name_length, ENC_ASCII|ENC_NA); - name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, name_length, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_epmd_name, tvb, offset, name_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &name); break; case EPMD_NAMES_REQ: @@ -195,7 +192,7 @@ dissect_epmd_response(packet_info *pinfo, tvbuff_t *tvb, gint offset, proto_tree guint8 type, result; guint32 port; guint16 name_length = 0; - const gchar *name = NULL; + const guint8 *name = NULL; conversation_t *conv = NULL; port = tvb_get_ntohl(tvb, offset); @@ -247,8 +244,7 @@ dissect_epmd_response(packet_info *pinfo, tvbuff_t *tvb, gint offset, proto_tree offset += 2; name_length = tvb_get_ntohs(tvb, offset); proto_tree_add_item(tree, hf_epmd_name_len, tvb, offset, 2, ENC_BIG_ENDIAN); - proto_tree_add_item(tree, hf_epmd_name, tvb, offset + 2, name_length, ENC_ASCII|ENC_NA); - name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 2, name_length, ENC_ASCII); + proto_tree_add_item_ret_string(tree, hf_epmd_name, tvb, offset + 2, name_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &name); offset += 2 + name_length; if (tvb_reported_length_remaining(tvb, offset) >= 2) { guint16 elen=0; diff --git a/epan/dissectors/packet-erldp.c b/epan/dissectors/packet-erldp.c index 7ae68b0427..d87fbda41b 100644 --- a/epan/dissectors/packet-erldp.c +++ b/epan/dissectors/packet-erldp.c @@ -179,7 +179,7 @@ static gint dissect_etf_dist_header(packet_info *pinfo _U_, tvbuff_t *tvb, gint gboolean new_entry, long_atom; proto_item *ti_acrs, *ti_acr, *ti_tmp; proto_tree *flags_tree, *acrs_tree, *acr_tree; - const gchar *str; + const guint8 *str; num = tvb_get_guint8(tvb, offset); proto_tree_add_item(tree, hf_erldp_num_atom_cache_refs, tvb, offset, 1, ENC_BIG_ENDIAN ); @@ -229,8 +229,7 @@ static gint dissect_etf_dist_header(packet_info *pinfo _U_, tvbuff_t *tvb, gint proto_tree_add_uint(acr_tree, hf_erldp_atom_length, tvb, offset, 1, atom_txt_len); offset++; } - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, atom_txt_len, ENC_ASCII); - proto_tree_add_item(acr_tree, hf_erldp_atom_text, tvb, offset, atom_txt_len, ENC_NA|ENC_ASCII); + proto_tree_add_item_ret_string(acr_tree, hf_erldp_atom_text, tvb, offset, atom_txt_len, ENC_NA|ENC_ASCII, wmem_packet_scope(), &str); proto_item_append_text(ti_acr, " - '%s'", str); offset += atom_txt_len; proto_item_set_len(ti_acr, offset - acr_offset); @@ -410,7 +409,7 @@ static void dissect_erldp_handshake(tvbuff_t *tvb, packet_info *pinfo, proto_tre gint i; gboolean is_challenge = FALSE; guint32 str_len; - const gchar *str; + const guint8 *str; proto_tree_add_item(tree, hf_erldp_length_2, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; @@ -436,8 +435,7 @@ static void dissect_erldp_handshake(tvbuff_t *tvb, packet_info *pinfo, proto_tre offset += 4; } str_len = tvb_captured_length_remaining(tvb, offset); - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, str_len, ENC_ASCII); - proto_tree_add_item(tree, hf_erldp_name, tvb, offset, str_len, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(tree, hf_erldp_name, tvb, offset, str_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); col_add_fstr(pinfo->cinfo, COL_INFO, "%s %s", (is_challenge) ? "SEND_CHALLENGE" : "SEND_NAME", str); break; @@ -457,8 +455,7 @@ static void dissect_erldp_handshake(tvbuff_t *tvb, packet_info *pinfo, proto_tre case 's' : str_len = tvb_captured_length_remaining(tvb, offset); - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, str_len, ENC_ASCII); - proto_tree_add_item(tree, hf_erldp_status, tvb, offset, str_len, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(tree, hf_erldp_status, tvb, offset, str_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); col_add_fstr(pinfo->cinfo, COL_INFO, "SEND_STATUS %s", str); break; } diff --git a/epan/dissectors/packet-exported_pdu.c b/epan/dissectors/packet-exported_pdu.c index b607bc0189..dcedd3409d 100644 --- a/epan/dissectors/packet-exported_pdu.c +++ b/epan/dissectors/packet-exported_pdu.c @@ -116,9 +116,9 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* guint16 tag; int tag_len; int next_proto_type = -1; - char *proto_name = NULL; - char *dissector_table = NULL; - char *col_proto_str = NULL; + const guint8 *proto_name = NULL; + const guint8 *dissector_table = NULL; + const guint8 *col_proto_str = NULL; dissector_handle_t proto_handle; mtp3_addr_pc_t *mtp3_addr; guint8 dvb_ci_dir; @@ -143,18 +143,15 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* switch(tag) { case EXP_PDU_TAG_PROTO_NAME: next_proto_type = EXPORTED_PDU_NEXT_PROTO_STR; - proto_name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tag_len, ENC_UTF_8|ENC_NA); - proto_tree_add_item(tag_tree, hf_exported_pdu_prot_name, tvb, offset, tag_len, ENC_UTF_8|ENC_NA); + proto_tree_add_item_ret_string(tag_tree, hf_exported_pdu_prot_name, tvb, offset, tag_len, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &proto_name); break; case EXP_PDU_TAG_HEUR_PROTO_NAME: next_proto_type = EXPORTED_PDU_NEXT_HEUR_PROTO_STR; - proto_name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tag_len, ENC_UTF_8|ENC_NA); - proto_tree_add_item(tag_tree, hf_exported_pdu_heur_prot_name, tvb, offset, tag_len, ENC_UTF_8|ENC_NA); + proto_tree_add_item_ret_string(tag_tree, hf_exported_pdu_heur_prot_name, tvb, offset, tag_len, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &proto_name); break; case EXP_PDU_TAG_DISSECTOR_TABLE_NAME: next_proto_type = EXPORTED_PDU_NEXT_DIS_TABLE_STR; - dissector_table = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tag_len, ENC_UTF_8 | ENC_NA); - proto_tree_add_item(tag_tree, hf_exported_pdu_dis_table_name, tvb, offset, tag_len, ENC_UTF_8 | ENC_NA); + proto_tree_add_item_ret_string(tag_tree, hf_exported_pdu_dis_table_name, tvb, offset, tag_len, ENC_UTF_8 | ENC_NA, wmem_packet_scope(), &dissector_table); break; case EXP_PDU_TAG_IPV4_SRC: proto_tree_add_item(tag_tree, hf_exported_pdu_ipv4_src, tvb, offset, 4, ENC_BIG_ENDIAN); @@ -240,8 +237,7 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* proto_tree_add_item(tag_tree, hf_exported_pdu_dis_table_val, tvb, offset, 4, ENC_BIG_ENDIAN); break; case EXP_PDU_TAG_COL_PROT_TEXT: - col_proto_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tag_len, ENC_UTF_8 | ENC_NA); - proto_tree_add_item(tag_tree, hf_exported_pdu_col_proto_str, tvb, offset, tag_len, ENC_UTF_8 | ENC_NA); + proto_tree_add_item_ret_string(tag_tree, hf_exported_pdu_col_proto_str, tvb, offset, tag_len, ENC_UTF_8 | ENC_NA, wmem_packet_scope(), &col_proto_str); break; case EXP_PDU_TAG_END_OF_OPT: break; diff --git a/epan/dissectors/packet-extreme.c b/epan/dissectors/packet-extreme.c index 178954706b..92693063fa 100644 --- a/epan/dissectors/packet-extreme.c +++ b/epan/dissectors/packet-extreme.c @@ -417,7 +417,7 @@ dissect_display_tlv(tvbuff_t *tvb, packet_info *pinfo, int offset, int length, p { proto_item *display_item; proto_tree *display_tree; - guint8 *display_name; + const guint8 *display_name; display_item = proto_tree_add_item(tree, hf_edp_display, tvb, offset, length, ENC_BIG_ENDIAN); @@ -428,11 +428,10 @@ dissect_display_tlv(tvbuff_t *tvb, packet_info *pinfo, int offset, int length, p offset += 4; length -= 4; - display_name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII); + proto_tree_add_item_ret_string(display_tree, hf_edp_display_string, tvb, offset, length, + ENC_ASCII, wmem_packet_scope(), &display_name); proto_item_append_text(display_item, ": \"%s\"", format_text(display_name, strlen(display_name))); - proto_tree_add_string(display_tree, hf_edp_display_string, tvb, offset, length, - display_name); } static int @@ -538,7 +537,7 @@ dissect_vlan_tlv(tvbuff_t *tvb, packet_info *pinfo, int offset, int length, prot proto_item *vlan_item; proto_tree *vlan_tree; guint16 vlan_id; - guint8 *vlan_name; + const guint8 *vlan_name; vlan_item = proto_tree_add_item(tree, hf_edp_vlan, tvb, offset, length, ENC_BIG_ENDIAN); @@ -608,11 +607,10 @@ dissect_vlan_tlv(tvbuff_t *tvb, packet_info *pinfo, int offset, int length, prot offset += 4; length -= 4; - vlan_name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII); + proto_tree_add_item_ret_string(vlan_tree, hf_edp_vlan_name, tvb, offset, length, + ENC_ASCII, wmem_packet_scope(), &vlan_name); proto_item_append_text(vlan_item, ", Name \"%s\"", format_text(vlan_name, strlen(vlan_name))); - proto_tree_add_string(vlan_tree, hf_edp_vlan_name, tvb, offset, length, - vlan_name); offset += length; diff --git a/epan/dissectors/packet-foundry.c b/epan/dissectors/packet-foundry.c index 3c9a92858a..5c046d8d84 100644 --- a/epan/dissectors/packet-foundry.c +++ b/epan/dissectors/packet-foundry.c @@ -137,7 +137,7 @@ dissect_string_tlv(tvbuff_t *tvb, packet_info *pinfo, int offset, int length, pr { proto_item *string_item; proto_tree *string_tree; - guint8 *string_value; + const guint8 *string_value; string_item = proto_tree_add_protocol_format(tree, hf_fdp_string, tvb, offset, length, "%s", type_string); @@ -148,13 +148,11 @@ dissect_string_tlv(tvbuff_t *tvb, packet_info *pinfo, int offset, int length, pr offset += 4; length -= 4; - string_value = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII); + proto_tree_add_item(string_tree, hf_fdp_string_data, tvb, offset, length, ENC_NA); + proto_tree_add_item_ret_string(string_tree, hf_fdp_string_text, tvb, offset, length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &string_value); proto_item_append_text(string_item, ": \"%s\"", format_text(string_value, strlen(string_value))); - proto_tree_add_item(string_tree, hf_fdp_string_data, tvb, offset, length, ENC_NA); - proto_tree_add_item(string_tree, hf_fdp_string_text, tvb, offset, length, ENC_ASCII|ENC_NA); - return offset; } diff --git a/epan/dissectors/packet-gearman.c b/epan/dissectors/packet-gearman.c index 7628429666..3d2ef94458 100644 --- a/epan/dissectors/packet-gearman.c +++ b/epan/dissectors/packet-gearman.c @@ -440,8 +440,9 @@ dissect_management_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (cmdlen == linelen && 0 == tvb_strneql(tvb, offset, GEARMAN_MGR_CMDS[i], cmdlen)) { - proto_tree_add_item(gearman_tree, hf_gearman_mgr_cmd, tvb, offset, cmdlen, ENC_ASCII|ENC_NA); - col_add_fstr(pinfo->cinfo, COL_INFO, "[MGR] %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, linelen, ENC_ASCII)); + const guint8* cmdstr; + proto_tree_add_item_ret_string(gearman_tree, hf_gearman_mgr_cmd, tvb, offset, cmdlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &cmdstr); + col_add_fstr(pinfo->cinfo, COL_INFO, "[MGR] %s", cmdstr); type = 1; break; } diff --git a/epan/dissectors/packet-gsm_a_dtap.c b/epan/dissectors/packet-gsm_a_dtap.c index 3ec0fe5e1b..343c313aeb 100644 --- a/epan/dissectors/packet-gsm_a_dtap.c +++ b/epan/dissectors/packet-gsm_a_dtap.c @@ -910,7 +910,6 @@ de_network_name(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 off guint32 curr_offset; guint8 coding_scheme, num_spare_bits; guint32 num_text_bits; - gchar *net_name = NULL; proto_item *item; curr_offset = offset; @@ -941,8 +940,7 @@ de_network_name(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, guint32 off proto_tree_add_ts_23_038_7bits_item(tree, hf_gsm_a_dtap_text_string, tvb, curr_offset<<3, num_text_bits/7); break; case 1: - net_name = tvb_get_string_enc(wmem_packet_scope(), tvb, curr_offset, (len - 1), ENC_UCS_2|ENC_BIG_ENDIAN); - proto_tree_add_string(tree, hf_gsm_a_dtap_text_string, tvb, curr_offset, len - 1, net_name); + proto_tree_add_item(tree, hf_gsm_a_dtap_text_string, tvb, curr_offset, len - 1, ENC_UCS_2|ENC_BIG_ENDIAN); break; default: proto_tree_add_expert(tree, pinfo, &ei_gsm_a_dtap_coding_scheme, tvb, curr_offset, len - 1); diff --git a/epan/dissectors/packet-gsm_map.c b/epan/dissectors/packet-gsm_map.c index 1dd367d364..37bbc875ab 100644 --- a/epan/dissectors/packet-gsm_map.c +++ b/epan/dissectors/packet-gsm_map.c @@ -5007,15 +5007,15 @@ dissect_gsm_map_ss_USSD_String(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int switch(sms_encoding){ case SMS_ENCODING_7BIT: case SMS_ENCODING_7BIT_LANG: - proto_tree_add_string(subtree, hf_gsm_map_ussd_string, parameter_tvb, 0, length, tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, 0, length, ENC_3GPP_TS_23_038_7BITS|ENC_NA)); + proto_tree_add_item(subtree, hf_gsm_map_ussd_string, parameter_tvb, 0, length, ENC_3GPP_TS_23_038_7BITS|ENC_NA); break; case SMS_ENCODING_8BIT: /* XXX - ASCII, or some extended ASCII? */ - proto_tree_add_string(subtree, hf_gsm_map_ussd_string, parameter_tvb, 0, length, tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, 0, length, ENC_ASCII|ENC_NA)); + proto_tree_add_item(subtree, hf_gsm_map_ussd_string, parameter_tvb, 0, length, ENC_ASCII|ENC_NA); break; case SMS_ENCODING_UCS2: case SMS_ENCODING_UCS2_LANG: - proto_tree_add_string(subtree, hf_gsm_map_ussd_string, parameter_tvb, 0, length, tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, 0, length, ENC_UCS_2|ENC_BIG_ENDIAN)); + proto_tree_add_item(subtree, hf_gsm_map_ussd_string, parameter_tvb, 0, length, ENC_UCS_2|ENC_BIG_ENDIAN); break; default: break; diff --git a/epan/dissectors/packet-hpfeeds.c b/epan/dissectors/packet-hpfeeds.c index 7b998e4c26..532995edef 100644 --- a/epan/dissectors/packet-hpfeeds.c +++ b/epan/dissectors/packet-hpfeeds.c @@ -179,7 +179,7 @@ dissect_hpfeeds_publish_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, { guint8 len = 0; heur_dtbl_entry_t *hdtbl_entry; - guint8 *strptr = NULL; + const guint8 *strptr = NULL; tvbuff_t *next_tvb; len = tvb_get_guint8(tvb, offset); @@ -192,15 +192,14 @@ dissect_hpfeeds_publish_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, offset += 1; /* get the channel name as ephemeral string to pass it to the heuristic decoders */ - strptr = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII); - proto_tree_add_item(tree, hf_hpfeeds_channel, tvb, offset, len, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(tree, hf_hpfeeds_channel, tvb, offset, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &strptr); offset += len; next_tvb = tvb_new_subset_remaining(tvb, offset); /* try the heuristic dissectors */ if (try_heuristic) { - if (dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree, &hdtbl_entry, strptr)) { + if (dissector_try_heuristic(heur_subdissector_list, next_tvb, pinfo, tree, &hdtbl_entry, (void*)strptr)) { return; } } diff --git a/epan/dissectors/packet-icep.c b/epan/dissectors/packet-icep.c index d45806f4fe..5bb16fe117 100644 --- a/epan/dissectors/packet-icep.c +++ b/epan/dissectors/packet-icep.c @@ -170,7 +170,7 @@ static const value_string icep_mode_vals[] = { * "*dest" is a null terminated version of the dissected Ice string. */ static void dissect_ice_string(packet_info *pinfo, proto_tree *tree, proto_item *item, int hf_icep, - tvbuff_t *tvb, guint32 offset, gint32 *consumed, char **dest) + tvbuff_t *tvb, guint32 offset, gint32 *consumed, const guint8 **dest) { /* p. 586 chapter 23.2.1 and p. 588 chapter 23.2.5 * string == Size + content @@ -180,7 +180,7 @@ static void dissect_ice_string(packet_info *pinfo, proto_tree *tree, proto_item */ guint32 Size = 0; - char *s = NULL; + const guint8 *s = NULL; (*consumed) = 0; @@ -240,8 +240,7 @@ static void dissect_ice_string(packet_info *pinfo, proto_tree *tree, proto_item if ( Size != 0 ) { - s = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, Size, ENC_ASCII); - proto_tree_add_string(tree, hf_icep, tvb, offset, Size, s); + proto_tree_add_item_ret_string(tree, hf_icep, tvb, offset, Size, ENC_ASCII, wmem_packet_scope(), &s); } else { s = wmem_strdup(wmem_packet_scope(), "(empty)"); /* display the 0x00 Size byte when click on a empty ice_string */ @@ -412,10 +411,10 @@ static void dissect_ice_context(packet_info *pinfo, proto_tree *tree, proto_item for ( i = 0; i < Size; i++ ) { /* key */ gint32 consumed_key = 0; - char *str_key = NULL; + const guint8 *str_key = NULL; /* value */ gint32 consumed_value = 0; - char *str_value = NULL; + const guint8 *str_value = NULL; proto_item *ti; proto_tree *context_tree; @@ -555,8 +554,8 @@ static void dissect_icep_request_common(tvbuff_t *tvb, guint32 offset, */ gint32 consumed = 0; - char *namestr = NULL; - char *opstr = NULL; + const guint8 *namestr = NULL; + const guint8 *opstr = NULL; (*total_consumed) = 0; diff --git a/epan/dissectors/packet-ieee80211-prism.c b/epan/dissectors/packet-ieee80211-prism.c index 9b804f6f91..0cc9f01f17 100644 --- a/epan/dissectors/packet-ieee80211-prism.c +++ b/epan/dissectors/packet-ieee80211-prism.c @@ -274,7 +274,7 @@ dissect_prism(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U guint32 msgcode, msglen, did; guint byte_order; guint16 status; - guint8 *devname_p; + const guint8 *devname_p; guint32 channel; guint32 rate; struct ieee_802_11_phdr phdr; @@ -334,8 +334,7 @@ dissect_prism(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U offset += 4; /* Device Name */ - proto_tree_add_item(prism_tree, hf_ieee80211_prism_devname, tvb, offset, 16, ENC_ASCII|ENC_NA); - devname_p = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 16, ENC_ASCII); + proto_tree_add_item_ret_string(prism_tree, hf_ieee80211_prism_devname, tvb, offset, 16, ENC_ASCII|ENC_NA, wmem_packet_scope(), &devname_p); offset += 16; col_add_fstr(pinfo->cinfo, COL_INFO, "Device: %s, Message 0x%x, Length %d", devname_p, msgcode, msglen); diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c index 2b6e8ebcfd..37cb8f79b9 100644 --- a/epan/dissectors/packet-ieee80211.c +++ b/epan/dissectors/packet-ieee80211.c @@ -6230,13 +6230,13 @@ static const value_string nai_realm_auth_param_id_vals[] = { static void dissect_nai_realm_list(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset, int end) { - guint16 count, len; - proto_item *item, *r_item; - int f_end, eap_end; - guint8 nai_len, eap_count, eap_len, auth_param_count, auth_param_len; - guint8 auth_param_id; - proto_tree *realm_tree, *eap_tree; - guint8 *realm; + guint16 count, len; + proto_item *item, *r_item; + int f_end, eap_end; + guint8 nai_len, eap_count, eap_len, auth_param_count, auth_param_len; + guint8 auth_param_id; + proto_tree *realm_tree, *eap_tree; + const guint8 *realm; count = tvb_get_letohs(tvb, offset); proto_tree_add_item(tree, hf_ieee80211_ff_anqp_nai_realm_count, @@ -6267,9 +6267,8 @@ dissect_nai_realm_list(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int "Invalid NAI Realm Data"); break; } - proto_tree_add_item(realm_tree, hf_ieee80211_ff_anqp_nai_realm, - tvb, offset, nai_len, ENC_ASCII|ENC_NA); - realm = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, nai_len, ENC_ASCII); + proto_tree_add_item_ret_string(realm_tree, hf_ieee80211_ff_anqp_nai_realm, + tvb, offset, nai_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &realm); if (realm) { proto_item_append_text(r_item, " (%s)", realm); } @@ -10596,6 +10595,7 @@ dissect_vendor_ie_aruba(proto_item *item, proto_tree *ietree, tvbuff_t *tvb, int offset, guint32 tag_len) { guint8 type; + const guint8* name; offset += 1; /* VS OUI Type */ tag_len -= 1; @@ -10611,9 +10611,9 @@ dissect_vendor_ie_aruba(proto_item *item, proto_tree *ietree, offset += 1; tag_len -= 1; - proto_tree_add_item (ietree, hf_ieee80211_vs_aruba_apname, tvb, - offset, tag_len, ENC_ASCII|ENC_NA); - proto_item_append_text(item, " (%s)", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tag_len, ENC_ASCII)); + proto_tree_add_item_ret_string(ietree, hf_ieee80211_vs_aruba_apname, tvb, + offset, tag_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &name); + proto_item_append_text(item, " (%s)", name); break; default: @@ -13853,6 +13853,7 @@ ieee80211_tag_country_info(packet_info *pinfo, proto_tree *tree, /* 7.3.2.9 Country information element (7) */ proto_tree *sub_tree; proto_item *sub_item; + const guint8* country_code; if (tag_len < 6) { expert_add_info_format(pinfo, ti_len, &ei_ieee80211_tag_length, @@ -13862,10 +13863,9 @@ ieee80211_tag_country_info(packet_info *pinfo, proto_tree *tree, offset += 2; - proto_tree_add_item(tree, hf_ieee80211_tag_country_info_code, - tvb, offset, 2, ENC_ASCII|ENC_NA); - proto_item_append_text(ti, ": Country Code %s", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 2, ENC_ASCII)); + proto_tree_add_item_ret_string(tree, hf_ieee80211_tag_country_info_code, + tvb, offset, 2, ENC_ASCII|ENC_NA, wmem_packet_scope(), &country_code); + proto_item_append_text(ti, ": Country Code %s", country_code); offset += 2; proto_tree_add_item(tree, hf_ieee80211_tag_country_info_env, @@ -15527,12 +15527,13 @@ add_tagged_field(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset case TAG_MESH_ID: { + const guint8* mesh_id; offset += 2; - proto_tree_add_item(tree, hf_ieee80211_mesh_id, tvb, offset, tag_len, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(tree, hf_ieee80211_mesh_id, tvb, offset, tag_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &mesh_id); if (tag_len > 0) { - col_append_fstr(pinfo->cinfo, COL_INFO, ", MESHID=%s", format_text(tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tag_len, ENC_ASCII), tag_len)); - proto_item_append_text(ti, ": %s", format_text(tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tag_len, ENC_ASCII), tag_len)); + col_append_fstr(pinfo->cinfo, COL_INFO, ", MESHID=%s", format_text(mesh_id, tag_len)); + proto_item_append_text(ti, ": %s", format_text(mesh_id, tag_len)); } break; diff --git a/epan/dissectors/packet-imf.c b/epan/dissectors/packet-imf.c index 0792a0bf38..b84ae91c3d 100644 --- a/epan/dissectors/packet-imf.c +++ b/epan/dissectors/packet-imf.c @@ -536,8 +536,9 @@ dissect_imf_siolabel(tvbuff_t *tvb, int offset, int length, proto_item *item, pa } if (tvb_strneql(tvb, item_offset, "marking", 7) == 0) { - proto_item_append_text(item, ": %s", tvb_get_string_enc(wmem_packet_scope(), tvb, value_offset, value_length, ENC_ASCII)); - proto_tree_add_item(tree, hf_imf_siolabel_marking, tvb, value_offset, value_length, ENC_ASCII|ENC_NA); + const guint8* marking; + proto_tree_add_item_ret_string(tree, hf_imf_siolabel_marking, tvb, value_offset, value_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &marking); + proto_item_append_text(item, ": %s", marking); } else if (tvb_strneql(tvb, item_offset, "fgcolor", 7) == 0) { proto_tree_add_item(tree, hf_imf_siolabel_fgcolor, tvb, value_offset, value_length, ENC_ASCII|ENC_NA); @@ -586,7 +587,7 @@ dissect_imf_siolabel(tvbuff_t *tvb, int offset, int length, proto_item *item, pa static void dissect_imf_content_type(tvbuff_t *tvb, int offset, int length, proto_item *item, - char **type, char **parameters) + const guint8 **type, const guint8 **parameters) { int first_colon; int end_offset; @@ -609,22 +610,14 @@ dissect_imf_content_type(tvbuff_t *tvb, int offset, int length, proto_item *item ct_tree = proto_item_add_subtree(item, ett_imf_content_type); len = first_colon - offset; - proto_tree_add_item(ct_tree, hf_imf_content_type_type, tvb, offset, len, ENC_ASCII|ENC_NA); - if(type) { - /* This string will be automatically freed */ - (*type) = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII); - } + proto_tree_add_item_ret_string(ct_tree, hf_imf_content_type_type, tvb, offset, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), type); end_offset = imf_find_field_end (tvb, first_colon + 1, offset + length, NULL); if (end_offset == -1) { /* No end found */ return; } len = end_offset - (first_colon + 1) - 2; /* Do not include the last CRLF */ - proto_tree_add_item(ct_tree, hf_imf_content_type_parameters, tvb, first_colon + 1, len, ENC_ASCII|ENC_NA); - if(parameters) { - /* This string will be automatically freed */ - (*parameters) = tvb_get_string_enc(wmem_packet_scope(), tvb, first_colon + 1, len, ENC_ASCII); - } + proto_tree_add_item_ret_string(ct_tree, hf_imf_content_type_parameters, tvb, first_colon + 1, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), parameters); } } @@ -685,9 +678,9 @@ dissect_imf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { proto_item *item; proto_tree *unknown_tree, *text_tree; - char *content_type_str = NULL; + const guint8 *content_type_str = NULL; char *content_encoding_str = NULL; - char *parameters = NULL; + const guint8 *parameters = NULL; int hf_id; gint start_offset = 0; gint value_offset = 0; @@ -830,7 +823,7 @@ dissect_imf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) next_tvb = tvb_new_subset_remaining(tvb, end_offset); } - dissector_try_string(media_type_dissector_table, content_type_str, next_tvb, pinfo, tree, parameters); + dissector_try_string(media_type_dissector_table, content_type_str, next_tvb, pinfo, tree, (void*)parameters); } else { /* just show the lines or highlight the rest of the buffer as message text */ diff --git a/epan/dissectors/packet-irc.c b/epan/dissectors/packet-irc.c index 64bd63def7..4a50e8c055 100644 --- a/epan/dissectors/packet-irc.c +++ b/epan/dissectors/packet-irc.c @@ -84,7 +84,7 @@ static ws_mempbrk_pattern pbrk_tag_delimiter; /* good candidate for dynamic port specification */ static void -dissect_irc_tag_data(proto_tree *tree, proto_item *item, tvbuff_t *tvb, int offset, int datalen, packet_info *pinfo, guint8* command) +dissect_irc_tag_data(proto_tree *tree, proto_item *item, tvbuff_t *tvb, int offset, int datalen, packet_info *pinfo, const guint8* command) { guchar found_start_needle = 0, found_end_needle = 0; @@ -117,17 +117,17 @@ dissect_irc_tag_data(proto_tree *tree, proto_item *item, tvbuff_t *tvb, int offs static void dissect_irc_request(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset, int linelen) { - proto_tree *request_tree, *command_tree = NULL; - proto_item *request_item; - int start_offset = offset; - int end_offset = start_offset+linelen; - gint eop_offset = -1, - eoc_offset = -1, - eocp_offset, - tag_start_offset, tag_end_offset; - guint8* str_command; - guchar found_tag_needle = 0; - gboolean first_command_param = TRUE; + proto_tree *request_tree, *command_tree = NULL; + proto_item *request_item; + int start_offset = offset; + int end_offset = start_offset+linelen; + gint eop_offset = -1, + eoc_offset = -1, + eocp_offset, + tag_start_offset, tag_end_offset; + const guint8 *str_command; + guchar found_tag_needle = 0; + gboolean first_command_param = TRUE; request_item = proto_tree_add_item(tree, hf_irc_request, tvb, offset, linelen, ENC_ASCII|ENC_NA); if (linelen <= 0) @@ -164,9 +164,9 @@ dissect_irc_request(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int off eoc_offset = tvb_find_guint8(tvb, offset, end_offset-offset, ' '); if (eoc_offset == -1) { - proto_tree_add_item(request_tree, hf_irc_request_command, tvb, offset, end_offset-offset, ENC_ASCII|ENC_NA); - col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset, end_offset-offset, ENC_ASCII|ENC_NA)); + const guint8* col_str; + proto_tree_add_item_ret_string(request_tree, hf_irc_request_command, tvb, offset, end_offset-offset, ENC_ASCII|ENC_NA, wmem_packet_scope(), &col_str); + col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", col_str); /* Warn if there is a "numeric" command */ if ((end_offset-offset == 3) && @@ -179,8 +179,7 @@ dissect_irc_request(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int off return; } - proto_tree_add_item(request_tree, hf_irc_request_command, tvb, offset, eoc_offset-offset, ENC_ASCII|ENC_NA); - str_command = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, eoc_offset-offset, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(request_tree, hf_irc_request_command, tvb, offset, eoc_offset-offset, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str_command); col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", str_command); /* Warn if there is a "numeric" command */ @@ -281,18 +280,18 @@ dissect_irc_request(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int off static void dissect_irc_response(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset, int linelen) { - proto_tree *response_tree, *command_tree = NULL; - proto_item *response_item, *hidden_item; - int start_offset = offset; - int end_offset = start_offset+linelen; - gint eop_offset = -1, - eoc_offset = -1, - eocp_offset, - tag_start_offset, tag_end_offset; - guint8* str_command; - guint16 num_command; - guchar found_tag_needle = 0; - gboolean first_command_param = TRUE; + proto_tree *response_tree, *command_tree = NULL; + proto_item *response_item, *hidden_item; + int start_offset = offset; + int end_offset = start_offset+linelen; + gint eop_offset = -1, + eoc_offset = -1, + eocp_offset, + tag_start_offset, tag_end_offset; + const guint8* str_command; + guint16 num_command; + guchar found_tag_needle = 0; + gboolean first_command_param = TRUE; response_item = proto_tree_add_item(tree, hf_irc_response, tvb, offset, linelen, ENC_ASCII|ENC_NA); if (linelen <= 0) @@ -329,9 +328,9 @@ dissect_irc_response(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int of eoc_offset = tvb_find_guint8(tvb, offset, end_offset-offset, ' '); if (eoc_offset == -1) { - proto_tree_add_item(response_tree, hf_irc_response_command, tvb, offset, end_offset-offset, ENC_ASCII|ENC_NA); - col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", - tvb_get_string_enc(wmem_packet_scope(), tvb, offset, end_offset-offset, ENC_ASCII|ENC_NA)); + const guint8* col_str; + proto_tree_add_item_ret_string(response_tree, hf_irc_response_command, tvb, offset, end_offset-offset, ENC_ASCII|ENC_NA, wmem_packet_scope(), &col_str); + col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", col_str); /* if response command is numeric, allow it to be filtered as an integer */ if ((end_offset-offset == 3) && @@ -346,8 +345,7 @@ dissect_irc_response(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int of return; } - proto_tree_add_item(response_tree, hf_irc_response_command, tvb, offset, eoc_offset-offset, ENC_ASCII|ENC_NA); - str_command = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, eoc_offset-offset, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(response_tree, hf_irc_response_command, tvb, offset, eoc_offset-offset, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str_command); col_append_fstr( pinfo->cinfo, COL_INFO, " (%s)", str_command); /* if response command is numeric, allow it to be filtered as an integer */ diff --git a/epan/dissectors/packet-isakmp.c b/epan/dissectors/packet-isakmp.c index a0e278e5d9..c04762a9a1 100644 --- a/epan/dissectors/packet-isakmp.c +++ b/epan/dissectors/packet-isakmp.c @@ -3759,6 +3759,7 @@ dissect_id(tvbuff_t *tvb, int offset, int length, proto_tree *tree, int isakmp_v guint16 port; proto_item *idit; proto_tree *idtree; + const guint8 *str; asn1_ctx_t asn1_ctx; asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo); @@ -3806,12 +3807,12 @@ dissect_id(tvbuff_t *tvb, int offset, int length, proto_tree *tree, int isakmp_v proto_item_append_text(idit, "%s", tvb_ip_to_str(tvb, offset)); break; case IKE_ID_FQDN: - proto_tree_add_item(idtree, hf_isakmp_id_data_fqdn, tvb, offset, length, ENC_ASCII|ENC_NA); - proto_item_append_text(idit, "%s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset,length, ENC_ASCII)); + proto_tree_add_item_ret_string(idtree, hf_isakmp_id_data_fqdn, tvb, offset, length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(idit, "%s", str); break; case IKE_ID_USER_FQDN: - proto_tree_add_item(idtree, hf_isakmp_id_data_user_fqdn, tvb, offset, length, ENC_ASCII|ENC_NA); - proto_item_append_text(idit, "%s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset,length, ENC_ASCII)); + proto_tree_add_item_ret_string(idtree, hf_isakmp_id_data_user_fqdn, tvb, offset, length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(idit, "%s", str); break; case IKE_ID_IPV4_ADDR_SUBNET: proto_tree_add_item(idtree, hf_isakmp_id_data_ipv4_addr, tvb, offset, 4, ENC_BIG_ENDIAN); @@ -4453,6 +4454,7 @@ dissect_config_attribute(tvbuff_t *tvb, packet_info *pinfo, proto_tree *cfg_attr proto_item *cfg_attr_type_item = NULL; proto_tree *sub_cfg_attr_type_tree = NULL; guint i; + const guint8* str; cfg_attr_type = tvb_get_ntohs(tvb, offset); optlen = tvb_get_ntohs(tvb, offset+2); @@ -4538,8 +4540,8 @@ dissect_config_attribute(tvbuff_t *tvb, packet_info *pinfo, proto_tree *cfg_attr } break; case APPLICATION_VERSION: /* 7 */ - proto_tree_add_item(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_application_version, tvb, offset, optlen, ENC_ASCII|ENC_NA); - proto_item_append_text(cfg_attr_type_item," : %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset,optlen, ENC_ASCII)); + proto_tree_add_item_ret_string(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_application_version, tvb, offset, optlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(cfg_attr_type_item," : %s", str); break; case INTERNAL_IP6_ADDRESS: /* 8 */ if (optlen%17 == 0) @@ -4661,49 +4663,49 @@ dissect_config_attribute(tvbuff_t *tvb, packet_info *pinfo, proto_tree *cfg_attr proto_item_append_text(cfg_attr_type_item," : %s", rval_to_str(tvb_get_ntohs(tvb, offset), cfgattr_xauth_type, "Unknown %d")); break; case XAUTH_USER_NAME: /* 16521 */ - proto_tree_add_item(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_user_name, tvb, offset, optlen, ENC_ASCII|ENC_NA); - proto_item_append_text(cfg_attr_type_item," : %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset,optlen, ENC_ASCII)); + proto_tree_add_item_ret_string(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_user_name, tvb, offset, optlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(cfg_attr_type_item," : %s", str); break; case XAUTH_USER_PASSWORD: /* 16522 */ - proto_tree_add_item(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_user_password, tvb, offset, optlen, ENC_ASCII|ENC_NA); - proto_item_append_text(cfg_attr_type_item," : %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset,optlen, ENC_ASCII)); + proto_tree_add_item_ret_string(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_user_password, tvb, offset, optlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(cfg_attr_type_item," : %s", str); break; case XAUTH_PASSCODE: /* 16523 */ - proto_tree_add_item(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_passcode, tvb, offset, optlen, ENC_ASCII|ENC_NA); - proto_item_append_text(cfg_attr_type_item," : %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset,optlen, ENC_ASCII)); + proto_tree_add_item_ret_string(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_passcode, tvb, offset, optlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(cfg_attr_type_item," : %s", str); break; case XAUTH_MESSAGE: /* 16524 */ - proto_tree_add_item(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_message, tvb, offset, optlen, ENC_ASCII|ENC_NA); - proto_item_append_text(cfg_attr_type_item," : %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset,optlen, ENC_ASCII)); + proto_tree_add_item_ret_string(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_message, tvb, offset, optlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(cfg_attr_type_item," : %s", str); break; case XAUTH_CHALLENGE: /* 16525 */ - proto_tree_add_item(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_challenge, tvb, offset, optlen, ENC_ASCII|ENC_NA); - proto_item_append_text(cfg_attr_type_item," : %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset,optlen, ENC_ASCII)); + proto_tree_add_item_ret_string(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_challenge, tvb, offset, optlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(cfg_attr_type_item," : %s", str); break; case XAUTH_DOMAIN: /* 16526 */ - proto_tree_add_item(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_domain, tvb, offset, optlen, ENC_ASCII|ENC_NA); - proto_item_append_text(cfg_attr_type_item," : %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset,optlen, ENC_ASCII)); + proto_tree_add_item_ret_string(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_domain, tvb, offset, optlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(cfg_attr_type_item," : %s", str); break; case XAUTH_STATUS: /* 16527 */ proto_tree_add_item(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_status, tvb, offset, optlen, ENC_BIG_ENDIAN); proto_item_append_text(cfg_attr_type_item," : %s", val_to_str(tvb_get_ntohs(tvb, offset), cfgattr_xauth_status, "Unknown %d")); break; case XAUTH_NEXT_PIN: /* 16528 */ - proto_tree_add_item(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_next_pin, tvb, offset, optlen, ENC_ASCII|ENC_NA); - proto_item_append_text(cfg_attr_type_item," : %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset,optlen, ENC_ASCII)); + proto_tree_add_item_ret_string(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_next_pin, tvb, offset, optlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(cfg_attr_type_item," : %s", str); break; case XAUTH_ANSWER: /* 16527 */ - proto_tree_add_item(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_answer, tvb, offset, optlen, ENC_ASCII|ENC_NA); - proto_item_append_text(cfg_attr_type_item," : %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset,optlen, ENC_ASCII)); + proto_tree_add_item_ret_string(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_xauth_answer, tvb, offset, optlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(cfg_attr_type_item," : %s", str); break; case UNITY_BANNER: /* 28672 */ - proto_tree_add_item(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_unity_banner, tvb, offset, optlen, ENC_ASCII|ENC_NA); - proto_item_append_text(cfg_attr_type_item," : %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset,optlen, ENC_ASCII)); + proto_tree_add_item_ret_string(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_unity_banner, tvb, offset, optlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(cfg_attr_type_item," : %s", str); break; case UNITY_DEF_DOMAIN: /* 28674 */ - proto_tree_add_item(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_unity_def_domain, tvb, offset, optlen, ENC_ASCII|ENC_NA); - proto_item_append_text(cfg_attr_type_item," : %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset,optlen, ENC_ASCII)); + proto_tree_add_item_ret_string(sub_cfg_attr_type_tree, hf_isakmp_cfg_attr_unity_def_domain, tvb, offset, optlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(cfg_attr_type_item," : %s", str); break; /* TODO: Support other UNITY Attributes ! */ default: diff --git a/epan/dissectors/packet-m2tp.c b/epan/dissectors/packet-m2tp.c index f00f08d189..1ed4e2622f 100644 --- a/epan/dissectors/packet-m2tp.c +++ b/epan/dissectors/packet-m2tp.c @@ -330,13 +330,12 @@ static void dissect_m2tp_info_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item) { guint16 length, info_string_length; - const char *info_string; + const guint8 *info_string; if (parameter_tree) { length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET); info_string_length = length - PARAMETER_HEADER_LENGTH; - info_string = tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, INFO_STRING_OFFSET, info_string_length, ENC_ASCII); - proto_tree_add_string(parameter_tree, hf_m2tp_info_string, parameter_tvb, INFO_STRING_OFFSET, info_string_length, info_string); + proto_tree_add_item_ret_string(parameter_tree, hf_m2tp_info_string, parameter_tvb, INFO_STRING_OFFSET, info_string_length, ENC_ASCII, wmem_packet_scope(), &info_string); proto_item_set_text(parameter_item, "Info String (%.*s)", info_string_length, info_string); } } diff --git a/epan/dissectors/packet-mikey.c b/epan/dissectors/packet-mikey.c index 403378b60f..333cb501da 100644 --- a/epan/dissectors/packet-mikey.c +++ b/epan/dissectors/packet-mikey.c @@ -912,12 +912,11 @@ dissect_payload_id(mikey_t *mikey _U_, tvbuff_t *tvb, packet_info *pinfo _U_, pr if (tree) { proto_item* parent; - proto_tree_add_item(tree, hf_mikey[POS_ID], tvb, 4, length, ENC_ASCII|ENC_NA); + const guint8* pos_id; + proto_tree_add_item_ret_string(tree, hf_mikey[POS_ID], tvb, 4, length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &pos_id); parent = proto_tree_get_parent(tree); - proto_item_append_text(parent, " %s: %s", - val_to_str_const(type, id_type_vals, "Unknown"), - tvb_get_string_enc(wmem_packet_scope(), tvb, 4, length, ENC_ASCII)); + proto_item_append_text(parent, " %s: %s", val_to_str_const(type, id_type_vals, "Unknown"), pos_id); } return 4 + length; @@ -940,12 +939,11 @@ dissect_payload_idr(mikey_t *mikey _U_, tvbuff_t *tvb, packet_info *pinfo _U_, p if (tree) { proto_item *parent; - proto_tree_add_item(tree, hf_mikey[POS_ID], tvb, 5, length, ENC_ASCII|ENC_NA); + const guint8* pos_id; + proto_tree_add_item_ret_string(tree, hf_mikey[POS_ID], tvb, 5, length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &pos_id); parent = proto_tree_get_parent(tree); - proto_item_append_text(parent, " %s: %s", - val_to_str_const(type, id_type_vals, "Unknown"), - tvb_get_string_enc(wmem_packet_scope(), tvb, 5, length, ENC_ASCII)); + proto_item_append_text(parent, " %s: %s", val_to_str_const(type, id_type_vals, "Unknown"), pos_id); } return 5 + length; diff --git a/epan/dissectors/packet-mip6.c b/epan/dissectors/packet-mip6.c index ecd79740b1..e96c00c25f 100644 --- a/epan/dissectors/packet-mip6.c +++ b/epan/dissectors/packet-mip6.c @@ -2168,8 +2168,8 @@ static void dissect_mip6_opt_mnid(const mip6_opt *optp _U_, tvbuff_t *tvb, int offset, guint optlen, packet_info *pinfo _U_, proto_tree *opt_tree, proto_item *hdr_item) { - int len; - gchar *str; + int len; + const guint8 *str; /* offset points to tag(opt) */ offset++; @@ -2183,8 +2183,7 @@ dissect_mip6_opt_mnid(const mip6_opt *optp _U_, tvbuff_t *tvb, int offset, len = optlen - MIP6_MNID_MNID_OFF; if (len > 0) { - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_UTF_8|ENC_NA); - proto_tree_add_string(opt_tree, hf_mip6_mnid_identifier, tvb, offset, len, str); + proto_tree_add_item_ret_string(opt_tree, hf_mip6_mnid_identifier, tvb, offset, len, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &str); proto_item_append_text(hdr_item, ": %s", str); } } @@ -2393,8 +2392,8 @@ static void dissect_mip6_opt_ssm(const mip6_opt *optp _U_, tvbuff_t *tvb, int offset, guint optlen, packet_info *pinfo _U_, proto_tree *opt_tree, proto_item *hdr_item _U_ ) { - int len; - guint8 *str; + int len; + const guint8 *str; /* offset points to tag(opt) */ offset++; @@ -2417,8 +2416,7 @@ dissect_mip6_opt_ssm(const mip6_opt *optp _U_, tvbuff_t *tvb, int offset, */ if (len > 0) { - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_UTF_8|ENC_NA); - proto_tree_add_string(opt_tree, hf_mip6_opt_ss_identifier, tvb, offset, len, str); + proto_tree_add_item_ret_string(opt_tree, hf_mip6_opt_ss_identifier, tvb, offset, len, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &str); proto_item_append_text(hdr_item, ": %s", str); } } @@ -3323,6 +3321,7 @@ dissect_pmip6_opt_acc_net_id(const mip6_opt *optp _U_, tvbuff_t *tvb, int offset proto_tree *subopt_tree; gint16 length, sub_opt_len; guint8 sub_opt, e_bit, net_name_len, ap_name_len; + const guint8 *ap_name; gint offset_end; /* offset points to tag(opt) */ @@ -3372,8 +3371,9 @@ dissect_pmip6_opt_acc_net_id(const mip6_opt *optp _U_, tvbuff_t *tvb, int offset offset++; if(e_bit == 0x80){ - proto_tree_add_item(subopt_tree, hf_mip6_opt_acc_net_id_sub_opt_net_name, tvb, offset, net_name_len, ENC_BIG_ENDIAN|ENC_UTF_8); - proto_item_append_text(ti, " Network Name: %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, net_name_len, ENC_UTF_8)); + const guint8* name; + proto_tree_add_item_ret_string(subopt_tree, hf_mip6_opt_acc_net_id_sub_opt_net_name, tvb, offset, net_name_len, ENC_BIG_ENDIAN|ENC_UTF_8, wmem_packet_scope(), &name); + proto_item_append_text(ti, " Network Name: %s", name); }else{ proto_tree_add_item(subopt_tree, hf_mip6_opt_acc_net_id_sub_opt_net_name_data, tvb, offset, net_name_len, ENC_BIG_ENDIAN|ENC_UTF_8); }; @@ -3383,8 +3383,8 @@ dissect_pmip6_opt_acc_net_id(const mip6_opt *optp _U_, tvbuff_t *tvb, int offset proto_tree_add_item(subopt_tree, hf_mip6_opt_acc_net_id_sub_opt_ap_name_len, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; - proto_tree_add_item(subopt_tree, hf_mip6_opt_acc_net_id_sub_opt_ap_name, tvb, offset, ap_name_len, ENC_BIG_ENDIAN|ENC_UTF_8); - proto_item_append_text(ti, " AP Name: %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, ap_name_len, ENC_UTF_8)); + proto_tree_add_item_ret_string(subopt_tree, hf_mip6_opt_acc_net_id_sub_opt_ap_name, tvb, offset, ap_name_len, ENC_BIG_ENDIAN|ENC_UTF_8, wmem_packet_scope(), &ap_name); + proto_item_append_text(ti, " AP Name: %s", ap_name); offset = offset+ap_name_len; break; diff --git a/epan/dissectors/packet-ms-mms.c b/epan/dissectors/packet-ms-mms.c index 85353a9166..4c3ba7de4c 100644 --- a/epan/dissectors/packet-ms-mms.c +++ b/epan/dissectors/packet-ms-mms.c @@ -431,7 +431,7 @@ static gint dissect_msmms_command(tvbuff_t *tvb, packet_info *pinfo, proto_tree /* Protocol name. Must be "MMS"... */ if (strncmp((char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 3, ENC_ASCII), "MMS", 3) != 0) { - return 0; + return offset; } proto_tree_add_item(msmms_common_command_tree, hf_msmms_command_protocol_type, tvb, offset, 4, ENC_ASCII|ENC_NA); offset += 4; @@ -796,11 +796,11 @@ static void dissect_client_transport_info(tvbuff_t *tvb, packet_info *pinfo, pro static void dissect_server_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset) { - guint32 server_version_length; - guint32 tool_version_length; - guint32 download_update_player_length; - guint32 password_encryption_type_length; - char *server_version; + guint32 server_version_length; + guint32 tool_version_length; + guint32 download_update_player_length; + guint32 password_encryption_type_length; + const guint8 *server_version; /* ErrorCode */ proto_tree_add_item(tree, hf_msmms_command_prefix1_error, tvb, offset, 4, ENC_LITTLE_ENDIAN); @@ -842,12 +842,10 @@ static void dissect_server_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t /* Server version string. */ if (server_version_length > 1) { - server_version = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, server_version_length*2, ENC_UTF_16|ENC_LITTLE_ENDIAN); - /* Server version string */ - proto_tree_add_item(tree, hf_msmms_command_server_version, tvb, + proto_tree_add_item_ret_string(tree, hf_msmms_command_server_version, tvb, offset, server_version_length*2, - ENC_UTF_16|ENC_LITTLE_ENDIAN); + ENC_UTF_16|ENC_LITTLE_ENDIAN, wmem_packet_scope(), &server_version); col_append_fstr(pinfo->cinfo, COL_INFO, " (version='%s')", format_text((guchar*)server_version, strlen(server_version))); @@ -887,7 +885,7 @@ static void dissect_server_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t static void dissect_client_player_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, guint length_remaining) { - char *player_info; + const guint8 *player_info; /* Flags */ proto_tree_add_item(tree, hf_msmms_command_prefix1, tvb, offset, 4, ENC_LITTLE_ENDIAN); @@ -899,11 +897,9 @@ static void dissect_client_player_info(tvbuff_t *tvb, packet_info *pinfo, proto_ offset += 4; /* Extract and show the string in tree and info column */ - player_info = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length_remaining - 12, ENC_UTF_16|ENC_LITTLE_ENDIAN); - - proto_tree_add_item(tree, hf_msmms_command_client_player_info, tvb, + proto_tree_add_item_ret_string(tree, hf_msmms_command_client_player_info, tvb, offset, length_remaining-12, - ENC_UTF_16|ENC_LITTLE_ENDIAN); + ENC_UTF_16|ENC_LITTLE_ENDIAN, wmem_packet_scope(), &player_info); col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", format_text((guchar*)player_info, strlen(player_info))); @@ -964,7 +960,7 @@ static void dissect_timing_test_response(tvbuff_t *tvb, proto_tree *tree, guint static void dissect_request_server_file(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, guint length_remaining) { - char *server_file; + const guint8 *server_file; /* Command Level */ proto_tree_add_item(tree, hf_msmms_command_prefix1_command_level, tvb, offset, 4, ENC_LITTLE_ENDIAN); @@ -976,11 +972,9 @@ static void dissect_request_server_file(tvbuff_t *tvb, packet_info *pinfo, proto offset += 4; /* File path on server */ - server_file = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length_remaining - 16, ENC_UTF_16|ENC_LITTLE_ENDIAN); - - proto_tree_add_item(tree, hf_msmms_command_server_file, tvb, + proto_tree_add_item_ret_string(tree, hf_msmms_command_server_file, tvb, offset, length_remaining-16, - ENC_UTF_16|ENC_LITTLE_ENDIAN); + ENC_UTF_16|ENC_LITTLE_ENDIAN, wmem_packet_scope(), &server_file); col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", format_text((guchar*)server_file, strlen(server_file))); diff --git a/epan/dissectors/packet-mswsp.c b/epan/dissectors/packet-mswsp.c index 9e8a8b5086..3e5b7ca969 100644 --- a/epan/dissectors/packet-mswsp.c +++ b/epan/dissectors/packet-mswsp.c @@ -214,7 +214,7 @@ struct CFullPropSpec { enum PRSPEC_Kind kind; union { guint32 propid; - char *name; + const guint8 *name; } u; }; @@ -260,7 +260,7 @@ struct CCoercionRestriction { /* 2.2.1.3 */ struct CContentRestriction { struct CFullPropSpec property; - const char *phrase; + const guint8 *phrase; guint32 lcid; guint32 method; }; @@ -273,7 +273,7 @@ struct CReuseWhere /*Restriction*/ { /* 2.2.1.5 */ struct CNatLanguageRestriction { struct CFullPropSpec property; - const char *phrase; + const guint8 *phrase; guint32 lcid; }; @@ -3388,8 +3388,7 @@ static int parse_CFullPropSpec(tvbuff_t *tvb, int offset, proto_tree *parent_tre if (v->kind == PRSPEC_LPWSTR) { int len = 2*v->u.propid; - v->u.name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_LITTLE_ENDIAN | ENC_UCS_2); - proto_tree_add_string(tree, hf_mswsp_cfullpropspec_propname, tvb, offset, len, v->u.name); + proto_tree_add_item_ret_string(tree, hf_mswsp_cfullpropspec_propname, tvb, offset, len, ENC_LITTLE_ENDIAN | ENC_UCS_2, wmem_packet_scope(), &v->u.name); offset += len; } @@ -3562,7 +3561,7 @@ static int parse_CContentRestriction(tvbuff_t *tvb, int offset, proto_tree *pare proto_item *item; va_list ap; guint32 cc; - const char *str, *txt; + const char *txt; va_start(ap, fmt); @@ -3579,9 +3578,7 @@ static int parse_CContentRestriction(tvbuff_t *tvb, int offset, proto_tree *pare proto_tree_add_uint(tree, hf_mswsp_ccontentrestrict_cc, tvb, offset, 4, cc); offset += 4; - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 2*cc, ENC_LITTLE_ENDIAN | ENC_UCS_2); - v->phrase = str; - proto_tree_add_string(tree, hf_mswsp_ccontentrestrict_phrase, tvb, offset, 2*cc, str); + proto_tree_add_item_ret_string(tree, hf_mswsp_ccontentrestrict_phrase, tvb, offset, 2*cc, ENC_LITTLE_ENDIAN | ENC_UCS_2, wmem_packet_scope(), &v->phrase); offset += 2*cc; offset = parse_padding(tvb, offset, 4, pad_tree, "Padding2"); @@ -3603,7 +3600,7 @@ int parse_CNatLanguageRestriction(tvbuff_t *tvb, int offset, proto_tree *parent_ proto_item *item; va_list ap; guint32 cc; - const char *str, *txt; + const char *txt; va_start(ap, fmt); @@ -3620,9 +3617,7 @@ int parse_CNatLanguageRestriction(tvbuff_t *tvb, int offset, proto_tree *parent_ proto_tree_add_uint(tree, hf_mswsp_natlangrestrict_cc, tvb, offset, 4, cc); offset += 4; - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 2*cc, ENC_LITTLE_ENDIAN | ENC_UCS_2); - v->phrase = str; - proto_tree_add_string(tree, hf_mswsp_natlangrestrict_phrase, tvb, offset, 2*cc, str); + proto_tree_add_item_ret_string(tree, hf_mswsp_natlangrestrict_phrase, tvb, offset, 2*cc, ENC_LITTLE_ENDIAN | ENC_UCS_2, wmem_packet_scope(), &v->phrase); offset += 2*cc; offset = parse_padding(tvb, offset, 4, pad_tree, "padding_lcid"); @@ -4649,14 +4644,15 @@ int parse_RANGEBOUNDARY(tvbuff_t *tvb, int offset, proto_tree *parent_tree, prot if (labelPresent) { guint32 ccLabel; + const guint8* label; offset = parse_padding(tvb, offset, 4, pad_tree, "paddingLabelPresent"); ccLabel = tvb_get_letohl(tvb, offset); proto_tree_add_item_ret_uint(tree, hf_mswsp_rangeboundry_cclabel, tvb, offset, 4, ENC_LITTLE_ENDIAN, &ccLabel); offset += 4; - proto_tree_add_item(tree, hf_mswsp_rangeboundry_label, tvb, offset, 2*ccLabel, ENC_LITTLE_ENDIAN | ENC_UCS_2); - proto_item_append_text(item, " Label: \"%s\"", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 2*ccLabel, ENC_LITTLE_ENDIAN | ENC_UCS_2)); + proto_tree_add_item_ret_string(tree, hf_mswsp_rangeboundry_label, tvb, offset, 2*ccLabel, ENC_LITTLE_ENDIAN | ENC_UCS_2, wmem_packet_scope(), &label); + proto_item_append_text(item, " Label: \"%s\"", label); offset += 2*ccLabel; } @@ -4732,7 +4728,7 @@ static int parse_CAggregSpec(tvbuff_t *tvb, int offset, proto_tree *parent_tree, va_list ap; guint8 type; guint32 ccAlias, idColumn; - const char *alias, *txt; + const char *txt; va_start(ap, fmt); txt = wmem_strdup_vprintf(wmem_packet_scope(), fmt, ap); @@ -4750,8 +4746,7 @@ static int parse_CAggregSpec(tvbuff_t *tvb, int offset, proto_tree *parent_tree, proto_tree_add_uint(tree, hf_mswsp_caggregspec_ccalias, tvb, offset, 1, ccAlias); offset += 4; - alias = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 2*ccAlias, ENC_LITTLE_ENDIAN | ENC_UCS_2); - proto_tree_add_string(tree, hf_mswsp_caggregspec_alias, tvb, offset, 2*ccAlias, alias); + proto_tree_add_item(tree, hf_mswsp_caggregspec_alias, tvb, offset, 2*ccAlias, ENC_LITTLE_ENDIAN | ENC_UCS_2); offset += 2*ccAlias; idColumn = tvb_get_letohl(tvb, offset); diff --git a/epan/dissectors/packet-mysql.c b/epan/dissectors/packet-mysql.c index 0e64bb1b38..f64590519a 100644 --- a/epan/dissectors/packet-mysql.c +++ b/epan/dissectors/packet-mysql.c @@ -972,6 +972,7 @@ add_connattrs_entry_to_tree(tvbuff_t *tvb, packet_info *pinfo _U_, proto_item *t int orig_offset = offset, lenfle; proto_item *ti; proto_tree *connattrs_tree; + const guint8 *str; ti = proto_tree_add_item(tree, hf_mysql_connattrs_attr, tvb, offset, 1, ENC_NA); connattrs_tree = proto_item_add_subtree(ti, ett_connattrs_attr); @@ -980,18 +981,16 @@ add_connattrs_entry_to_tree(tvbuff_t *tvb, packet_info *pinfo _U_, proto_item *t proto_tree_add_uint64(connattrs_tree, hf_mysql_connattrs_name_length, tvb, offset, lenfle, lenstr); offset += lenfle; - tvb_ensure_bytes_exist64(tvb, offset, lenstr); - proto_tree_add_item(connattrs_tree, hf_mysql_connattrs_name, tvb, offset, (gint)lenstr, ENC_ASCII|ENC_NA); - proto_item_append_text(ti, " - %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, (int)lenstr, ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(connattrs_tree, hf_mysql_connattrs_name, tvb, offset, (gint)lenstr, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(ti, " - %s", str); offset += (int)lenstr; lenfle = tvb_get_fle(tvb, offset, &lenstr, NULL); proto_tree_add_uint64(connattrs_tree, hf_mysql_connattrs_value_length, tvb, offset, lenfle, lenstr); offset += lenfle; - tvb_ensure_bytes_exist64(tvb, offset, lenstr); - proto_tree_add_item(connattrs_tree, hf_mysql_connattrs_value, tvb, offset, (gint)lenstr, ENC_ASCII|ENC_NA); - proto_item_append_text(ti, ": %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, (int)lenstr, ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(connattrs_tree, hf_mysql_connattrs_value, tvb, offset, (gint)lenstr, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(ti, ": %s", str); offset += (int)lenstr; proto_item_set_len(ti, offset - orig_offset); diff --git a/epan/dissectors/packet-netflow.c b/epan/dissectors/packet-netflow.c index 1a3c3443bf..f82f8c6838 100644 --- a/epan/dissectors/packet-netflow.c +++ b/epan/dissectors/packet-netflow.c @@ -5134,9 +5134,9 @@ dissect_v9_v10_pdu_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pdutree, case 341: /* informationElementName */ { - char *string = (char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII); - ti = proto_tree_add_item(pdutree, hf_cflow_information_element_name, - tvb, offset, length, ENC_UTF_8|ENC_NA); + const guint8 *string; + ti = proto_tree_add_item_ret_string(pdutree, hf_cflow_information_element_name, + tvb, offset, length, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &string); /* Add name of element to root for this flow */ proto_item_append_text(pdutree, " [%s]", string); } @@ -6395,9 +6395,9 @@ dissect_v9_v10_pdu_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pdutree, break; case ((VENDOR_IXIA << 16) | 111): { - char *string = (char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII); - ti = proto_tree_add_item(pdutree, hf_pie_ixia_l7_application_name, - tvb, offset, length, ENC_ASCII|ENC_NA); + const guint8 *string; + ti = proto_tree_add_item_ret_string(pdutree, hf_pie_ixia_l7_application_name, + tvb, offset, length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &string); proto_item_append_text(pdutree, " (%s)", string); } diff --git a/epan/dissectors/packet-netlink-route.c b/epan/dissectors/packet-netlink-route.c index 6bcdbfdbc8..ef14bf1f5b 100644 --- a/epan/dissectors/packet-netlink-route.c +++ b/epan/dissectors/packet-netlink-route.c @@ -464,11 +464,12 @@ static int dissect_netlink_route_ifla_attrs(tvbuff_t *tvb, struct netlink_route_info *info, proto_tree *tree, int rta_type, int offset, int len) { enum ws_ifla_attr_type type = (enum ws_ifla_attr_type) rta_type; + const guint8* str; switch (type) { case WS_IFLA_IFNAME: - proto_item_append_text(tree, ": %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII | ENC_NA)); - proto_tree_add_item(tree, &hfi_netlink_route_ifla_ifname, tvb, offset, len, ENC_ASCII | ENC_NA); + proto_tree_add_item_ret_string(tree, hfi_netlink_route_ifla_ifname.id, tvb, offset, len, ENC_ASCII | ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(tree, ": %s", str); return 1; case WS_IFLA_MTU: @@ -575,11 +576,12 @@ static int dissect_netlink_route_ifa_attrs(tvbuff_t *tvb, struct netlink_route_info *info _U_, proto_tree *tree, int rta_type, int offset, int len) { enum ws_ifa_attr_type type = (enum ws_ifa_attr_type) rta_type; + const guint8* str; switch (type) { case WS_IFA_LABEL: - proto_item_append_text(tree, ": %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII | ENC_NA)); - proto_tree_add_item(tree, &hfi_netlink_route_ifa_label, tvb, offset, len, ENC_ASCII | ENC_NA); + proto_tree_add_item_ret_string(tree, hfi_netlink_route_ifa_label.id, tvb, offset, len, ENC_ASCII | ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(tree, ": %s", str); return 1; default: diff --git a/epan/dissectors/packet-ntlmssp.c b/epan/dissectors/packet-ntlmssp.c index 5ce7f3d63d..3bf15bcbc4 100644 --- a/epan/dissectors/packet-ntlmssp.c +++ b/epan/dissectors/packet-ntlmssp.c @@ -1220,13 +1220,13 @@ dissect_ntlmssp_target_info_list(tvbuff_t *tvb, packet_info *pinfo, proto_tree * item_offset = target_info_offset; while (item_offset < (target_info_offset + target_info_length) && (item_type != NTLM_TARGET_INFO_END)) { - proto_item *target_info_tf; - proto_tree *target_info_tree; - guint32 content_offset; - guint16 content_length; - guint32 type_offset; - guint32 len_offset; - const gchar *text = NULL; + proto_item *target_info_tf; + proto_tree *target_info_tree; + guint32 content_offset; + guint16 content_length; + guint32 type_offset; + guint32 len_offset; + const guint8 *text = NULL; int **hf_array_p = tif_p->hf_attr_array_p; @@ -1256,8 +1256,7 @@ dissect_ntlmssp_target_info_list(tvbuff_t *tvb, packet_info *pinfo, proto_tree * case NTLM_TARGET_INFO_DNS_DOMAIN_NAME: case NTLM_TARGET_INFO_DNS_TREE_NAME: case NTLM_TARGET_INFO_TARGET_NAME: - text = tvb_get_string_enc(wmem_packet_scope(), tvb, content_offset, content_length, ENC_UTF_16|ENC_LITTLE_ENDIAN); - proto_tree_add_string(target_info_tree, *hf_array_p[item_type], tvb, content_offset, content_length, text); + proto_tree_add_item_ret_string(target_info_tree, *hf_array_p[item_type], tvb, content_offset, content_length, ENC_UTF_16|ENC_LITTLE_ENDIAN, wmem_packet_scope(), &text); proto_item_append_text(target_info_tf, ": %s", text); break; diff --git a/epan/dissectors/packet-obex.c b/epan/dissectors/packet-obex.c index 52f8ce7bf5..9ef9202378 100644 --- a/epan/dissectors/packet-obex.c +++ b/epan/dissectors/packet-obex.c @@ -1960,11 +1960,13 @@ dissect_headers(proto_tree *tree, tvbuff_t *tvb, int offset, packet_info *pinfo, break; case 0x44: /* Time (ISO8601) */ - proto_tree_add_item(hdr_tree, hf_time_iso8601, tvb, offset, value_length, ENC_ASCII | ENC_NA); - proto_item_append_text(hdr_tree, ": \"%s\"", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, value_length, ENC_ASCII)); + { + const guint8* time_str; + proto_tree_add_item_ret_string(hdr_tree, hf_time_iso8601, tvb, offset, value_length, ENC_ASCII | ENC_NA, wmem_packet_scope(), &time_str); + proto_item_append_text(hdr_tree, ": \"%s\"", time_str); offset += value_length; - + } break; case 0x48: /* Body */ case 0x49: /* End Of Body */ @@ -2058,11 +2060,13 @@ dissect_headers(proto_tree *tree, tvbuff_t *tvb, int offset, packet_info *pinfo, break; case 0x51: /* Object Class */ - proto_tree_add_item(hdr_tree, hf_object_class, tvb, offset, value_length, ENC_ASCII | ENC_NA); - proto_item_append_text(hdr_tree, ": \"%s\"", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, value_length, ENC_ASCII)); + { + const guint8* obj_str; + proto_tree_add_item_ret_string(hdr_tree, hf_object_class, tvb, offset, value_length, ENC_ASCII | ENC_NA, wmem_packet_scope(), &obj_str); + proto_item_append_text(hdr_tree, ": \"%s\"", obj_str); offset += value_length; - + } break; case 0x52: /* Session Parameter */ while (value_length) { diff --git a/epan/dissectors/packet-opsi.c b/epan/dissectors/packet-opsi.c index bcbf2426fc..bccf467d9a 100644 --- a/epan/dissectors/packet-opsi.c +++ b/epan/dissectors/packet-opsi.c @@ -428,27 +428,23 @@ static gboolean opsi_desegment = TRUE; static void decode_string_attribute(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, int* hfValue, int offset, int length) { - guint8* pbuffer; if (length < 4) { expert_add_info(pinfo, item, &ei_opsi_short_attribute); return; } - pbuffer=tvb_get_string_enc(wmem_packet_scope(), tvb, offset+4, length-4, ENC_ASCII); - proto_tree_add_string(tree, *hfValue, tvb, offset+4, length-4, pbuffer); + proto_tree_add_item(tree, *hfValue, tvb, offset+4, length-4, ENC_ASCII|ENC_NA); } static void decode_ipv4_attribute(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *item, int* hfValue, int offset, int length) { - guint32 ip_address; if (length < 8) { expert_add_info(pinfo, item, &ei_opsi_short_attribute); return; } - ip_address = tvb_get_ipv4(tvb, offset+4); - proto_tree_add_ipv4(tree, *hfValue, tvb, offset+4, 4, ip_address); + proto_tree_add_item(tree, *hfValue, tvb, offset+4, 4, ENC_BIG_ENDIAN); } static void @@ -458,7 +454,7 @@ decode_longint_attribute(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pr expert_add_info(pinfo, item, &ei_opsi_short_attribute); return; } - proto_tree_add_uint(tree, *hfValue, tvb, offset+4, 4, tvb_get_ntohl(tvb, offset+4)); + proto_tree_add_item(tree, *hfValue, tvb, offset+4, 4, ENC_BIG_ENDIAN); } static void diff --git a/epan/dissectors/packet-pana.c b/epan/dissectors/packet-pana.c index b06cde6bef..6be6c215e8 100644 --- a/epan/dissectors/packet-pana.c +++ b/epan/dissectors/packet-pana.c @@ -381,10 +381,8 @@ dissect_avps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *avp_tree) break; } case PANA_UTF8STRING: { - guint8 *data = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, avp_data_length, ENC_UTF_8); - proto_tree_add_string_format(single_avp_tree, hf_pana_avp_data_string, tvb, - offset, avp_data_length, data, - "UTF8String: %s", data); + proto_tree_add_item(single_avp_tree, hf_pana_avp_data_string, tvb, + offset, avp_data_length, ENC_UTF_8|ENC_NA); break; } case PANA_OCTET_STRING: { @@ -849,7 +847,7 @@ proto_register_pana(void) NULL, HFILL } }, { &hf_pana_avp_data_string, - { "Value", "pana.avp.data.string", + { "UTF8String", "pana.avp.data.string", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } }, diff --git a/epan/dissectors/packet-pflog.c b/epan/dissectors/packet-pflog.c index 9fe5d83de9..7f97bb6a2c 100644 --- a/epan/dissectors/packet-pflog.c +++ b/epan/dissectors/packet-pflog.c @@ -166,7 +166,7 @@ dissect_pflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U proto_item *ti = NULL, *ti_len; int length; guint8 af, action; - guint8 *ifname; + const guint8 *ifname; guint32 rulenr; guint8 pad_len = 3; gint offset = 0; @@ -197,8 +197,7 @@ dissect_pflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U proto_tree_add_item(pflog_tree, hf_pflog_reason, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; - proto_tree_add_item(pflog_tree, hf_pflog_ifname, tvb, offset, 16, ENC_ASCII|ENC_NA); - ifname = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 16, ENC_ASCII); + proto_tree_add_item_ret_string(pflog_tree, hf_pflog_ifname, tvb, offset, 16, ENC_ASCII|ENC_NA, wmem_packet_scope(), &ifname); offset += 16; proto_tree_add_item(pflog_tree, hf_pflog_ruleset, tvb, offset, 16, ENC_ASCII|ENC_NA); @@ -428,7 +427,7 @@ dissect_old_pflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat proto_tree *pflog_tree; proto_item *ti; guint32 af; - guint8 *ifname; + const guint8 *ifname; guint16 rnr, action; gint offset = 0; @@ -442,8 +441,7 @@ dissect_old_pflog(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat af = tvb_get_ntohl(tvb, offset); offset +=4; - proto_tree_add_item(pflog_tree, hf_old_pflog_ifname, tvb, offset, 16, ENC_ASCII|ENC_NA); - ifname = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 16, ENC_ASCII); + proto_tree_add_item_ret_string(pflog_tree, hf_old_pflog_ifname, tvb, offset, 16, ENC_ASCII|ENC_NA, wmem_packet_scope(), &ifname); offset +=16; proto_tree_add_item(pflog_tree, hf_old_pflog_rnr, tvb, offset, 2, ENC_BIG_ENDIAN); diff --git a/epan/dissectors/packet-ppcap.c b/epan/dissectors/packet-ppcap.c index 61480822ca..30628c8555 100644 --- a/epan/dissectors/packet-ppcap.c +++ b/epan/dissectors/packet-ppcap.c @@ -408,9 +408,8 @@ dissect_ppcap_destination_address(tvbuff_t *tvb, packet_info * pinfo, proto_tree else if (key2 == 4) { - char *string; - string = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, msg_len, ENC_UTF_8|ENC_NA); - proto_tree_add_string(ppcap_tree1, hf_ppcap_destination_nodeid, tvb, offset, msg_len, string); + const guint8 *string; + proto_tree_add_item_ret_string(ppcap_tree1, hf_ppcap_destination_nodeid, tvb, offset, msg_len, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &string); set_address_tvb(&pinfo->net_dst, AT_STRINGZ, msg_len, tvb, offset); copy_address_shallow(&pinfo->dst, &pinfo->net_dst); } diff --git a/epan/dissectors/packet-pppoe.c b/epan/dissectors/packet-pppoe.c index f13391a2ad..05081dd9e5 100644 --- a/epan/dissectors/packet-pppoe.c +++ b/epan/dissectors/packet-pppoe.c @@ -483,11 +483,13 @@ dissect_pppoe_tags(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tr } break; case PPPOE_TAG_AC_NAME: - proto_tree_add_item(pppoe_tree, hf_pppoed_tag_ac_name, tvb, - tagstart+4, poe_tag_length, ENC_ASCII|ENC_NA); + { + const guint8* str; + proto_tree_add_item_ret_string(pppoe_tree, hf_pppoed_tag_ac_name, tvb, + tagstart+4, poe_tag_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); /* Show AC-Name in info column */ - col_append_fstr(pinfo->cinfo, COL_INFO, " AC-Name='%s'", - tvb_get_string_enc(wmem_packet_scope(), tvb, tagstart+4, poe_tag_length, ENC_ASCII|ENC_NA)); + col_append_fstr(pinfo->cinfo, COL_INFO, " AC-Name='%s'", str); + } break; case PPPOE_TAG_HOST_UNIQ: proto_tree_add_item(pppoe_tree, hf_pppoed_tag_host_uniq, tvb, diff --git a/epan/dissectors/packet-ptpip.c b/epan/dissectors/packet-ptpip.c index 94c5086b39..ef0edd55e3 100644 --- a/epan/dissectors/packet-ptpip.c +++ b/epan/dissectors/packet-ptpip.c @@ -995,18 +995,13 @@ void dissect_ptp_transactionID(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr */ void dissect_ptpIP_unicode_name(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint16 *offset) { - guint8 *name; - gint nameLen; + const guint8 *name; + gint nameLen; nameLen = tvb_unicode_strsize(tvb, *offset); - name = tvb_get_string_enc(wmem_packet_scope(), tvb, *offset, nameLen, ENC_UTF_16|ENC_LITTLE_ENDIAN); - proto_tree_add_string(tree, hf_ptpIP_name, tvb, *offset, nameLen, name); + proto_tree_add_item_ret_string(tree, hf_ptpIP_name, tvb, *offset, nameLen, ENC_UTF_16|ENC_LITTLE_ENDIAN, wmem_packet_scope(), &name); *offset += nameLen; - col_append_fstr( - pinfo->cinfo, - COL_INFO, - " Name: %s", - name); + col_append_fstr(pinfo->cinfo, COL_INFO, " Name: %s", name); } /** Method dissects the protocol version from the packets. diff --git a/epan/dissectors/packet-quake2.c b/epan/dissectors/packet-quake2.c index bb061a9f94..10a0297f7e 100644 --- a/epan/dissectors/packet-quake2.c +++ b/epan/dissectors/packet-quake2.c @@ -88,7 +88,6 @@ dissect_quake2_ConnectionlessPacket(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int direction _U_) { proto_tree *cl_tree; - guint8 *text; int len; int offset; @@ -104,9 +103,8 @@ dissect_quake2_ConnectionlessPacket(tvbuff_t *tvb, packet_info *pinfo _U_, offset = 4; len = tvb_captured_length_remaining(tvb, offset); - text = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII); - proto_tree_add_string(cl_tree, hf_quake2_connectionless_text, - tvb, offset, len, text); + proto_tree_add_item(cl_tree, hf_quake2_connectionless_text, + tvb, offset, len, ENC_ASCII|ENC_NA); /*offset += len;*/ /* we should analyse the result 'text' a bit further */ diff --git a/epan/dissectors/packet-quic.c b/epan/dissectors/packet-quic.c index b451f9b252..11323bda58 100644 --- a/epan/dissectors/packet-quic.c +++ b/epan/dissectors/packet-quic.c @@ -1158,13 +1158,14 @@ dissect_quic_tag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *quic_tree, guint while(tag_number){ proto_tree *tag_tree, *ti_len, *ti_tag, *ti_type; guint32 offset_end, tag; + const guint8* tag_str; ti_tag = proto_tree_add_item(quic_tree, hf_quic_tags, tvb, offset, 8, ENC_NA); tag_tree = proto_item_add_subtree(ti_tag, ett_quic_tag_value); - ti_type = proto_tree_add_item(tag_tree, hf_quic_tag_type, tvb, offset, 4, ENC_ASCII|ENC_NA); + ti_type = proto_tree_add_item_ret_string(tag_tree, hf_quic_tag_type, tvb, offset, 4, ENC_ASCII|ENC_NA, wmem_packet_scope(), &tag_str); tag = tvb_get_ntohl(tvb, offset); proto_item_append_text(ti_type, " (%s)", val_to_str(tag, tag_vals, "Unknown")); - proto_item_append_text(ti_tag, ": %s (%s)", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 4, ENC_ASCII|ENC_NA), val_to_str(tag, tag_vals, "Unknown")); + proto_item_append_text(ti_tag, ": %s (%s)", tag_str, val_to_str(tag, tag_vals, "Unknown")); offset += 4; proto_tree_add_item(tag_tree, hf_quic_tag_offset_end, tvb, offset, 4, ENC_LITTLE_ENDIAN); @@ -1192,14 +1193,14 @@ dissect_quic_tag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *quic_tree, guint tag_len -= tag_len; break; case TAG_SNI: - proto_tree_add_item(tag_tree, hf_quic_tag_sni, tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA); - proto_item_append_text(ti_tag, ": %s", tvb_get_string_enc(wmem_packet_scope(), tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(tag_tree, hf_quic_tag_sni, tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &tag_str); + proto_item_append_text(ti_tag, ": %s", tag_str); tag_offset += tag_len; tag_len -= tag_len; break; case TAG_VER: - proto_tree_add_item(tag_tree, hf_quic_tag_ver, tvb, tag_offset_start + tag_offset, 4, ENC_ASCII|ENC_NA); - proto_item_append_text(ti_tag, " %s", tvb_get_string_enc(wmem_packet_scope(), tvb, tag_offset_start + tag_offset, 4, ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(tag_tree, hf_quic_tag_ver, tvb, tag_offset_start + tag_offset, 4, ENC_ASCII|ENC_NA, wmem_packet_scope(), &tag_str); + proto_item_append_text(ti_tag, " %s", tag_str); tag_offset += 4; tag_len -= 4; break; @@ -1211,14 +1212,14 @@ dissect_quic_tag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *quic_tree, guint } break; case TAG_PDMD: - proto_tree_add_item(tag_tree, hf_quic_tag_pdmd, tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA); - proto_item_append_text(ti_tag, ": %s", tvb_get_string_enc(wmem_packet_scope(), tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(tag_tree, hf_quic_tag_pdmd, tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &tag_str); + proto_item_append_text(ti_tag, ": %s", tag_str); tag_offset += tag_len; tag_len -= tag_len; break; case TAG_UAID: - proto_tree_add_item(tag_tree, hf_quic_tag_uaid, tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA); - proto_item_append_text(ti_tag, ": %s", tvb_get_string_enc(wmem_packet_scope(), tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA)); + proto_tree_add_item_ret_string(tag_tree, hf_quic_tag_uaid, tvb, tag_offset_start + tag_offset, tag_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &tag_str); + proto_item_append_text(ti_tag, ": %s", tag_str); tag_offset += tag_len; tag_len -= tag_len; break; @@ -1571,6 +1572,7 @@ dissect_quic_frame_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *quic_tree } else { /* Special Frame Types */ guint32 stream_id = 0, message_tag; + const guint8* message_tag_str; ftflags_tree = proto_item_add_subtree(ti_ftflags, ett_quic_ftflags); proto_tree_add_item(ftflags_tree, hf_quic_frame_type_stream , tvb, offset, 1, ENC_LITTLE_ENDIAN); @@ -1603,10 +1605,10 @@ dissect_quic_frame_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *quic_tree offset += len_data; } - ti = proto_tree_add_item(ft_tree, hf_quic_tag, tvb, offset, 4, ENC_ASCII|ENC_NA); + ti = proto_tree_add_item_ret_string(ft_tree, hf_quic_tag, tvb, offset, 4, ENC_ASCII|ENC_NA, wmem_packet_scope(), &message_tag_str); message_tag = tvb_get_ntohl(tvb, offset); proto_item_append_text(ti, " (%s)", val_to_str(message_tag, message_tag_vals, "Unknown Tag")); - proto_item_append_text(ti_ft, " Stream ID:%u, Type: %s (%s)", stream_id, tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 4, ENC_ASCII|ENC_NA), val_to_str(message_tag, message_tag_vals, "Unknown Tag")); + proto_item_append_text(ti_ft, " Stream ID:%u, Type: %s (%s)", stream_id, message_tag_str, val_to_str(message_tag, message_tag_vals, "Unknown Tag")); col_add_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str(message_tag, message_tag_vals, "Unknown")); offset += 4; diff --git a/epan/dissectors/packet-radius.c b/epan/dissectors/packet-radius.c index 066aab4c13..b49f0967d1 100644 --- a/epan/dissectors/packet-radius.c +++ b/epan/dissectors/packet-radius.c @@ -894,6 +894,7 @@ dissect_rfc4675_egress_vlan_name(proto_tree *tree, tvbuff_t *tvb, packet_info *p { int len; guint8 tag; + const guint8 *name; len = tvb_reported_length(tvb); if (len < 2) @@ -902,10 +903,10 @@ dissect_rfc4675_egress_vlan_name(proto_tree *tree, tvbuff_t *tvb, packet_info *p proto_tree_add_item(tree, hf_radius_egress_vlan_name_tag, tvb, 0, 1, ENC_BIG_ENDIAN); tag = tvb_get_guint8(tvb, 0); len -= 1; - proto_tree_add_item(tree, hf_radius_egress_vlan_name, tvb, 1, len, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(tree, hf_radius_egress_vlan_name, tvb, 1, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &name); return wmem_strdup_printf(wmem_packet_scope(), "%s, Vlan Name: %s", - val_to_str_const(tag, egress_vlan_tag_vals, "Unknown"), tvb_get_string_enc(wmem_packet_scope(), tvb, 1, len, ENC_ASCII|ENC_NA)); + val_to_str_const(tag, egress_vlan_tag_vals, "Unknown"), name); } static void diff --git a/epan/dissectors/packet-rpcap.c b/epan/dissectors/packet-rpcap.c index fc510cba76..da428e5683 100644 --- a/epan/dissectors/packet-rpcap.c +++ b/epan/dissectors/packet-rpcap.c @@ -489,8 +489,9 @@ dissect_rpcap_findalldevs_if (tvbuff_t *tvb, packet_info *pinfo _U_, offset += 2; if (namelen) { - proto_item_append_text (ti, ": %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, namelen, ENC_ASCII)); - proto_tree_add_item (tree, hf_if_name, tvb, offset, namelen, ENC_ASCII|ENC_NA); + const guint8* name; + proto_tree_add_item_ret_string(tree, hf_if_name, tvb, offset, namelen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &name); + proto_item_append_text (ti, ": %s", name); offset += namelen; } @@ -654,14 +655,12 @@ dissect_rpcap_auth_request (tvbuff_t *tvb, packet_info *pinfo _U_, if (type == RPCAP_RMTAUTH_NULL) { proto_item_append_text (ti, " (none)"); } else if (type == RPCAP_RMTAUTH_PWD) { - guint8 *username, *password; + const guint8 *username, *password; - username = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, slen1, ENC_ASCII); - proto_tree_add_item (tree, hf_auth_username, tvb, offset, slen1, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(tree, hf_auth_username, tvb, offset, slen1, ENC_ASCII|ENC_NA, wmem_packet_scope(), &username); offset += slen1; - password = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, slen2, ENC_ASCII); - proto_tree_add_item (tree, hf_auth_password, tvb, offset, slen2, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(tree, hf_auth_password, tvb, offset, slen2, ENC_ASCII|ENC_NA, wmem_packet_scope(), &password); offset += slen2; proto_item_append_text (ti, " (%s/%s)", username, password); diff --git a/epan/dissectors/packet-rsvp.c b/epan/dissectors/packet-rsvp.c index c00706169c..d61c53a175 100644 --- a/epan/dissectors/packet-rsvp.c +++ b/epan/dissectors/packet-rsvp.c @@ -5974,11 +5974,11 @@ dissect_rsvp_call_id(proto_tree *ti, packet_info* pinfo, proto_tree *rsvp_object int offset, int obj_length, int rsvp_class _U_, int c_type) { - int type = 0; - const char *str; - int offset2 = offset + 4; - int offset3, offset4, len; - proto_tree *ti2 = NULL; + int type = 0; + const guint8 *str; + int offset2 = offset + 4; + int offset3, offset4, len; + proto_tree *ti2 = NULL; proto_item_set_text(ti, "CALL-ID: "); switch(c_type) { @@ -6008,12 +6008,10 @@ dissect_rsvp_call_id(proto_tree *ti, packet_info* pinfo, proto_tree *rsvp_object proto_tree_add_uint_format_value(rsvp_object_tree, hf_rsvp_ctype, tvb, offset+3, 1, c_type, "2 (globally unique)"); ti2 = proto_tree_add_item(rsvp_object_tree, hf_rsvp_call_id_address_type, tvb, offset2, 1, ENC_BIG_ENDIAN); - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset2 + 1, 3, ENC_ASCII); - proto_tree_add_item(rsvp_object_tree, hf_rsvp_call_id_international_segment, tvb, offset2 + 1, 3, ENC_NA|ENC_ASCII); + proto_tree_add_item_ret_string(rsvp_object_tree, hf_rsvp_call_id_international_segment, tvb, offset2 + 1, 3, ENC_NA|ENC_ASCII, wmem_packet_scope(), &str); proto_item_append_text(ti, "Globally-Unique. Addr Type: %s. Intl Segment: %s. ", val_to_str(type, address_type_vals, "Unknown (%u)"), str); - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset2 + 4, 12, ENC_ASCII); - proto_tree_add_item(rsvp_object_tree, hf_rsvp_call_id_national_segment, tvb, offset2 + 4, 12, ENC_NA|ENC_ASCII); + proto_tree_add_item_ret_string(rsvp_object_tree, hf_rsvp_call_id_national_segment, tvb, offset2 + 4, 12, ENC_NA|ENC_ASCII, wmem_packet_scope(), &str); proto_item_append_text(ti, "Natl Segment: %s. ", str); } diff --git a/epan/dissectors/packet-rtcp.c b/epan/dissectors/packet-rtcp.c index eba149fd5e..2f3650f2b9 100644 --- a/epan/dissectors/packet-rtcp.c +++ b/epan/dissectors/packet-rtcp.c @@ -2015,15 +2015,13 @@ dissect_rtcp_bye( tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tre } if ( tvb_reported_length_remaining( tvb, offset ) > 0 ) { - char *reason_text; /* Bye reason consists of an 8 bit length l and a string with length l */ reason_length = tvb_get_guint8( tvb, offset ); proto_tree_add_item( tree, hf_rtcp_sdes_length, tvb, offset, 1, ENC_BIG_ENDIAN ); offset++; reason_offset = offset; - reason_text = (char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, reason_length, ENC_ASCII); - proto_tree_add_string( tree, hf_rtcp_sdes_text, tvb, offset, reason_length, reason_text ); + proto_tree_add_item( tree, hf_rtcp_sdes_text, tvb, offset, reason_length, ENC_ASCII|ENC_NA); offset += reason_length; } diff --git a/epan/dissectors/packet-rtpproxy.c b/epan/dissectors/packet-rtpproxy.c index e75f713acb..dafb30aa16 100644 --- a/epan/dissectors/packet-rtpproxy.c +++ b/epan/dissectors/packet-rtpproxy.c @@ -437,7 +437,7 @@ rtpproxy_add_parameter(tvbuff_t *tvb, packet_info *pinfo, proto_tree *rtpproxy_t } static rtpproxy_info_t * -rtpproxy_add_tid(gboolean is_request, tvbuff_t *tvb, packet_info *pinfo, proto_tree *rtpproxy_tree, rtpproxy_conv_info_t *rtpproxy_conv, gchar* cookie) +rtpproxy_add_tid(gboolean is_request, tvbuff_t *tvb, packet_info *pinfo, proto_tree *rtpproxy_tree, rtpproxy_conv_info_t *rtpproxy_conv, const guint8* cookie) { rtpproxy_info_t *rtpproxy_info; proto_item *pi; @@ -532,13 +532,13 @@ dissect_rtpproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data guint tmp2; gint realsize = 0; guint8* rawstr; - guint8* tmpstr; + const guint8* tmpstr; proto_item *ti; proto_item *ti2; proto_tree *rtpproxy_tree; conversation_t *conversation; rtpproxy_conv_info_t *rtpproxy_conv; - gchar* cookie = NULL; + const guint8* cookie = NULL; /* For RT(C)P setup */ address addr; guint16 port; @@ -566,8 +566,7 @@ dissect_rtpproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data ti = proto_tree_add_item(tree, proto_rtpproxy, tvb, 0, -1, ENC_NA); rtpproxy_tree = proto_item_add_subtree(ti, ett_rtpproxy); - proto_tree_add_item(rtpproxy_tree, hf_rtpproxy_cookie, tvb, 0, offset, ENC_ASCII | ENC_NA); - cookie = tvb_get_string_enc(wmem_packet_scope(), tvb, 0, offset, ENC_ASCII); + proto_tree_add_item_ret_string(rtpproxy_tree, hf_rtpproxy_cookie, tvb, 0, offset, ENC_ASCII | ENC_NA, wmem_packet_scope(), &cookie); /* Skip whitespace */ offset = tvb_skip_wsp(tvb, offset+1, -1); @@ -650,8 +649,7 @@ dissect_rtpproxy(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data if ((tmp == 'v') && (offset + (gint)strlen("VF YYYYMMDD") <= realsize)){ /* Skip whitespace between "VF" and "YYYYMMDD" tokens */ new_offset = tvb_skip_wsp(tvb, offset + ((guint)strlen("VF") + 1), -1); - ti = proto_tree_add_item(rtpproxy_tree, hf_rtpproxy_version_request, tvb, new_offset, (gint)strlen("YYYYMMDD"), ENC_ASCII | ENC_NA); - tmpstr = tvb_get_string_enc(wmem_packet_scope(), tvb, new_offset, (gint)strlen("YYYYMMDD"), ENC_ASCII); + ti = proto_tree_add_item_ret_string(rtpproxy_tree, hf_rtpproxy_version_request, tvb, new_offset, (gint)strlen("YYYYMMDD"), ENC_ASCII | ENC_NA, wmem_packet_scope(), &tmpstr); proto_item_append_text(ti, " (%s)", str_to_str(tmpstr, versiontypenames, "Unknown")); break; } diff --git a/epan/dissectors/packet-rtps.c b/epan/dissectors/packet-rtps.c index df58366d96..8d6664fe8d 100644 --- a/epan/dissectors/packet-rtps.c +++ b/epan/dissectors/packet-rtps.c @@ -2162,12 +2162,9 @@ gint rtps_util_add_string(proto_tree *tree, tvbuff_t *tvb, gint offset, guint8 *retVal = NULL; guint32 size = NEXT_guint32(tvb, offset, little_endian); - if (size > 0) { - retVal = tvb_get_string_enc(wmem_packet_scope(), tvb, offset+4, size, ENC_ASCII); - } + retVal = tvb_get_string_enc(wmem_packet_scope(), tvb, offset+4, size, ENC_ASCII); - proto_tree_add_string(tree, hf_item, tvb, offset, size+4, - (size == 0) ? (const guint8 *)"" : retVal); + proto_tree_add_string(tree, hf_item, tvb, offset, size+4, retVal); /* NDDS align strings at 4-bytes word. So: * string_length: 4 -> buffer_length = 4; @@ -2297,11 +2294,7 @@ gint rtps_util_add_seq_string(proto_tree *tree, tvbuff_t *tvb, gint offset, for (i = 0; i < num_strings; ++i) { size = NEXT_guint32(tvb, offset, little_endian); - if (size > 0) { - retVal = tvb_get_string_enc(wmem_packet_scope(), tvb, offset+4, size, ENC_ASCII); - } else { - retVal = (const guint8 *)""; - } + retVal = tvb_get_string_enc(wmem_packet_scope(), tvb, offset+4, size, ENC_ASCII); proto_tree_add_string_format(string_tree, hf_string, tvb, offset, size+4, retVal, "%s[%d]: %s", label, i, retVal); @@ -5279,11 +5272,7 @@ static gboolean dissect_parameter_sequence_v1(proto_tree *rtps_parameter_tree, p temp_offset = offset+4; while(seq_size-- > 0) { prop_size = NEXT_guint32(tvb, temp_offset, little_endian); - if (prop_size > 0) { - propName = tvb_get_string_enc(wmem_packet_scope(), tvb, temp_offset+4, prop_size, ENC_ASCII); - } else { - propName = (const guint8 *)""; - } + propName = tvb_get_string_enc(wmem_packet_scope(), tvb, temp_offset+4, prop_size, ENC_ASCII); /* NDDS align strings at 4-bytes word. */ str_length = (4 + ((prop_size + 3) & 0xfffffffc)); @@ -5292,11 +5281,7 @@ static gboolean dissect_parameter_sequence_v1(proto_tree *rtps_parameter_tree, p temp_offset += str_length; prop_size = NEXT_guint32(tvb, temp_offset, little_endian); - if (prop_size > 0) { - propValue = tvb_get_string_enc(wmem_packet_scope(), tvb, temp_offset+4, prop_size, ENC_ASCII); - } else { - propValue = (const guint8 *)""; - } + propValue = tvb_get_string_enc(wmem_packet_scope(), tvb, temp_offset+4, prop_size, ENC_ASCII); /* NDDS align strings at 4-bytes word. */ str_length = (4 + ((prop_size + 3) & 0xfffffffc)); diff --git a/epan/dissectors/packet-s7comm.c b/epan/dissectors/packet-s7comm.c index 648a11ff97..fd7b2684a7 100644 --- a/epan/dissectors/packet-s7comm.c +++ b/epan/dissectors/packet-s7comm.c @@ -2748,7 +2748,7 @@ s7comm_decode_pistart_parameters(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree *param_tree, - gchar *servicename, + const guint8 *servicename, guint8 nfields, /* number of fields used */ guint hf[12], /* array with header fields */ guint32 offset) @@ -2794,9 +2794,9 @@ s7comm_decode_pi_service(tvbuff_t *tvb, guint32 paramoffset; guint8 count; guint8 i; - gchar *servicename; - gchar *str; - gchar *str1; + const guint8 *servicename; + const guint8 *str; + const guint8 *str1; guint16 blocktype; guint hf[13]; int pi_servicename_idx; @@ -2833,8 +2833,7 @@ s7comm_decode_pi_service(tvbuff_t *tvb, len = tvb_get_guint8(tvb, offset); proto_tree_add_uint(tree, hf_s7comm_piservice_string_len, tvb, offset, 1, len); offset += 1; - servicename = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII); - item = proto_tree_add_item(tree, hf_s7comm_piservice_servicename, tvb, offset, len, ENC_ASCII|ENC_NA); + item = proto_tree_add_item_ret_string(tree, hf_s7comm_piservice_servicename, tvb, offset, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &servicename); offset += len; /* get the index position in pi_service_names, and add infotext with description to the item */ @@ -2863,8 +2862,7 @@ s7comm_decode_pi_service(tvbuff_t *tvb, itemadd = proto_tree_add_item(file_tree, hf_s7comm_data_blockcontrol_block_type, tvb, paramoffset, 2, ENC_ASCII|ENC_NA); proto_item_append_text(itemadd, " (%s)", val_to_str(blocktype, blocktype_names, "Unknown Block type: 0x%04x")); paramoffset += 2; - str = tvb_get_string_enc(wmem_packet_scope(), tvb, paramoffset, 5, ENC_ASCII); - proto_tree_add_item(file_tree, hf_s7comm_data_blockcontrol_block_num, tvb, paramoffset, 5, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(file_tree, hf_s7comm_data_blockcontrol_block_num, tvb, paramoffset, 5, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); paramoffset += 5; proto_item_append_text(file_tree, " [%s %d]", val_to_str(blocktype, blocktype_names, "Unknown Block type: 0x%04x"), @@ -2889,8 +2887,7 @@ s7comm_decode_pi_service(tvbuff_t *tvb, proto_item_append_text(tree, " -> %s()", servicename); col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s()", servicename); } else { - str1 = tvb_get_string_enc(wmem_packet_scope(), tvb, paramoffset, paramlen, ENC_ASCII); - proto_tree_add_item(param_tree, hf_s7comm_data_plccontrol_argument, tvb, paramoffset, paramlen, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(param_tree, hf_s7comm_data_plccontrol_argument, tvb, paramoffset, paramlen, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str1); proto_item_append_text(param_tree, ": (\"%s\")", str1); proto_item_append_text(tree, " -> %s(\"%s\")", servicename, str1); col_append_fstr(pinfo->cinfo, COL_INFO, " -> %s(\"%s\")", servicename, str1); @@ -3190,7 +3187,7 @@ s7comm_decode_plc_controls_filename(tvbuff_t *tvb, guint32 offset) { guint8 len; - guint8 *str; + const guint8 *str; guint16 blocktype; gboolean is_plcfilename; proto_item *item = NULL; @@ -3217,8 +3214,7 @@ s7comm_decode_plc_controls_filename(tvbuff_t *tvb, itemadd = proto_tree_add_item(file_tree, hf_s7comm_data_blockcontrol_block_type, tvb, offset, 2, ENC_ASCII|ENC_NA); proto_item_append_text(itemadd, " (%s)", val_to_str(blocktype, blocktype_names, "Unknown Block type: 0x%04x")); offset += 2; - str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 5, ENC_ASCII); - proto_tree_add_item(file_tree, hf_s7comm_data_blockcontrol_block_num, tvb, offset, 5, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(file_tree, hf_s7comm_data_blockcontrol_block_num, tvb, offset, 5, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); offset += 5; proto_item_append_text(file_tree, " [%s %d]", val_to_str(blocktype, blocktype_names, "Unknown Block type: 0x%04x"), @@ -4284,7 +4280,7 @@ s7comm_decode_ud_block_subfunc(tvbuff_t *tvb, { guint16 count; guint16 i; - guint8 *pBlocknumber; + const guint8 *pBlocknumber; guint16 blocknumber; guint8 blocktype; guint16 blocktype16; @@ -4370,8 +4366,7 @@ s7comm_decode_ud_block_subfunc(tvbuff_t *tvb, itemadd = proto_tree_add_item(data_tree, hf_s7comm_ud_blockinfo_block_type, tvb, offset, 2, ENC_ASCII|ENC_NA); proto_item_append_text(itemadd, " (%s)", val_to_str(blocktype16, blocktype_names, "Unknown Block type: 0x%04x")); offset += 2; - proto_tree_add_item(data_tree, hf_s7comm_ud_blockinfo_block_num_ascii, tvb, offset, 5, ENC_ASCII|ENC_NA); - pBlocknumber = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 5, ENC_ASCII); + proto_tree_add_item_ret_string(data_tree, hf_s7comm_ud_blockinfo_block_num_ascii, tvb, offset, 5, ENC_ASCII|ENC_NA, wmem_packet_scope(), &pBlocknumber); proto_item_append_text(data_tree, " [%s %d]", val_to_str(blocktype16, blocktype_names, "Unknown Block type: 0x%04x"), atoi(pBlocknumber)); diff --git a/epan/dissectors/packet-sametime.c b/epan/dissectors/packet-sametime.c index 28db6da0d0..d8c2627612 100644 --- a/epan/dissectors/packet-sametime.c +++ b/epan/dissectors/packet-sametime.c @@ -234,8 +234,7 @@ add_text_item(tvbuff_t *tvb, proto_tree *tree, int offset, int hf) proto_tree_add_item(tree, hf_sametime_field_length, tvb, offset, 2, ENC_BIG_ENDIAN); /* add string */ - proto_tree_add_string(tree, hf, tvb, offset + 2, length, - tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 2, length, ENC_ASCII|ENC_NA)); + proto_tree_add_item(tree, hf, tvb, offset + 2, length, ENC_ASCII|ENC_NA); } return 2 + length; diff --git a/epan/dissectors/packet-sbus.c b/epan/dissectors/packet-sbus.c index 565e1563f2..f5b947da17 100644 --- a/epan/dissectors/packet-sbus.c +++ b/epan/dissectors/packet-sbus.c @@ -1593,14 +1593,10 @@ dissect_sbus(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_ /* Response: Firmware version */ case SBUS_RD_PROGRAM_VERSION: /*PCD type*/ - tmp_string = tvb_get_string_enc(wmem_packet_scope(), tvb , offset, 5, ENC_ASCII); - proto_tree_add_string(sbus_tree, - hf_sbus_cpu_type, tvb, offset, 5, tmp_string); + proto_tree_add_item(sbus_tree, hf_sbus_cpu_type, tvb, offset, 5, ENC_ASCII|ENC_NA); offset += 5; /*FW version*/ - tmp_string = tvb_get_string_enc(wmem_packet_scope(), tvb , offset, 3, ENC_ASCII); - proto_tree_add_string(sbus_tree, - hf_sbus_fw_version, tvb, offset, 3, tmp_string); + proto_tree_add_item(sbus_tree, hf_sbus_fw_version, tvb, offset, 3, ENC_ASCII|ENC_NA); offset += 4; break; diff --git a/epan/dissectors/packet-sdp.c b/epan/dissectors/packet-sdp.c index 9d61558427..479b827ee5 100644 --- a/epan/dissectors/packet-sdp.c +++ b/epan/dissectors/packet-sdp.c @@ -246,13 +246,13 @@ typedef struct { /* Data that is retrieved from a packet, but does not need to be kept */ typedef struct { - char *connection_address; /* there should actually be SDP_MAX_RTP_CHANNELS of these too */ - char *connection_type; + char *connection_address; /* there should actually be SDP_MAX_RTP_CHANNELS of these too */ + const guint8 *connection_type; /* media_type is for 'audio', 'video', etc, so per-stream */ - char *media_type[SDP_MAX_RTP_CHANNELS]; - char *media_port[SDP_MAX_RTP_CHANNELS]; - char *media_proto[SDP_MAX_RTP_CHANNELS]; - guint8 media_count; + const guint8 *media_type[SDP_MAX_RTP_CHANNELS]; + const guint8 *media_port[SDP_MAX_RTP_CHANNELS]; + const guint8 *media_proto[SDP_MAX_RTP_CHANNELS]; + guint8 media_count; /* MSRP transport info (as set while parsing path attribute) */ gboolean msrp_transport_address_set; @@ -544,13 +544,10 @@ dissect_sdp_connection_info(tvbuff_t *tvb, proto_item* ti, return; /* Save connection address type */ - media_info->connection_type = (char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tokenlen, ENC_UTF_8|ENC_NA); - - DPRINT(("parsed connection line type=%s", media_info->connection_type)); - - proto_tree_add_item(sdp_connection_info_tree, + proto_tree_add_item_ret_string(sdp_connection_info_tree, hf_connection_info_address_type, tvb, offset, tokenlen, - ENC_UTF_8|ENC_NA); + ENC_UTF_8|ENC_NA, wmem_packet_scope(), &media_info->connection_type); + DPRINT(("parsed connection line type=%s", media_info->connection_type)); offset = next_offset + 1; /* Find the connection address */ @@ -751,15 +748,15 @@ static void dissect_sdp_encryption_key(tvbuff_t *tvb, proto_item * ti) { } static void dissect_key_mgmt(tvbuff_t *tvb, packet_info * pinfo, proto_item * ti) { - gchar *data_p = NULL; - gchar *prtcl_id = NULL; - gint len; - tvbuff_t *keymgmt_tvb; - int found_match = 0; - proto_tree *key_tree; - gint next_offset; - gint offset = 0; - gint tokenlen; + gchar *data_p = NULL; + const guint8 *prtcl_id = NULL; + gint len; + tvbuff_t *keymgmt_tvb; + int found_match = 0; + proto_tree *key_tree; + gint next_offset; + gint offset = 0; + gint tokenlen; key_tree = proto_item_add_subtree(ti, ett_sdp_key_mgmt); @@ -767,9 +764,7 @@ static void dissect_key_mgmt(tvbuff_t *tvb, packet_info * pinfo, proto_item * ti if (tokenlen == 0) return; - prtcl_id = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tokenlen, ENC_UTF_8|ENC_NA); - - proto_tree_add_item(key_tree, hf_key_mgmt_prtcl_id, tvb, offset, tokenlen, ENC_UTF_8|ENC_NA); + proto_tree_add_item_ret_string(key_tree, hf_key_mgmt_prtcl_id, tvb, offset, tokenlen, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &prtcl_id); offset = next_offset + 1; @@ -801,9 +796,9 @@ static void dissect_key_mgmt(tvbuff_t *tvb, packet_info * pinfo, proto_item * ti static void dissect_sdp_session_attribute(tvbuff_t *tvb, packet_info * pinfo, proto_item * ti) { - proto_tree *sdp_session_attribute_tree; - gint offset, next_offset, tokenlen; - guint8 *field_name; + proto_tree *sdp_session_attribute_tree; + gint offset, next_offset, tokenlen; + const guint8 *field_name; offset = 0; @@ -817,10 +812,8 @@ static void dissect_sdp_session_attribute(tvbuff_t *tvb, packet_info * pinfo, pr tokenlen = next_offset - offset; - proto_tree_add_item(sdp_session_attribute_tree, hf_session_attribute_field, - tvb, offset, tokenlen, ENC_UTF_8|ENC_NA); - - field_name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tokenlen, ENC_UTF_8|ENC_NA); + proto_tree_add_item_ret_string(sdp_session_attribute_tree, hf_session_attribute_field, + tvb, offset, tokenlen, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &field_name); offset = next_offset + 1; @@ -885,10 +878,8 @@ dissect_sdp_media(tvbuff_t *tvb, proto_item *ti, return; /* Type of media session */ - proto_tree_add_item(sdp_media_tree, hf_media_media, tvb, offset, tokenlen, - ENC_UTF_8|ENC_NA); - - media_info->media_type[media_info->media_count] = (char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tokenlen, ENC_UTF_8|ENC_NA); + proto_tree_add_item_ret_string(sdp_media_tree, hf_media_media, tvb, offset, tokenlen, + ENC_UTF_8|ENC_NA, wmem_packet_scope(), &media_info->media_type[media_info->media_count]); DPRINT(("parsed media_type=%s, for media_count=%d", media_info->media_type[media_info->media_count], @@ -905,14 +896,11 @@ dissect_sdp_media(tvbuff_t *tvb, proto_item *ti, if (next_offset != -1) { tokenlen = next_offset - offset; /* Save port info */ - media_info->media_port[media_info->media_count] = (char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tokenlen, ENC_UTF_8|ENC_NA); - + it = proto_tree_add_item_ret_string(sdp_media_tree, hf_media_port_string, tvb, offset, tokenlen, + ENC_UTF_8|ENC_NA, wmem_packet_scope(), &media_info->media_port[media_info->media_count]); DPRINT(("parsed media_port=%s, for media_count=%d", media_info->media_port[media_info->media_count], media_info->media_count)); - - it = proto_tree_add_string(sdp_media_tree, hf_media_port_string, tvb, offset, tokenlen, - media_info->media_port[media_info->media_count]); if (g_ascii_isdigit(media_info->media_port[media_info->media_count][0])) { PROTO_ITEM_SET_HIDDEN(it); proto_tree_add_uint(sdp_media_tree, hf_media_port, tvb, offset, tokenlen, @@ -935,13 +923,11 @@ dissect_sdp_media(tvbuff_t *tvb, proto_item *ti, return; /* Save port info */ - media_info->media_port[media_info->media_count] = (char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tokenlen, ENC_UTF_8|ENC_NA); + it = proto_tree_add_item_ret_string(sdp_media_tree, hf_media_port_string, tvb, offset, tokenlen, + ENC_UTF_8|ENC_NA, wmem_packet_scope(), &media_info->media_port[media_info->media_count]); DPRINT(("parsed media_port=%s, for media_count=%d", media_info->media_port[media_info->media_count], media_info->media_count)); - /* XXX Remember Port */ - it = proto_tree_add_string(sdp_media_tree, hf_media_port_string, tvb, offset, tokenlen, - media_info->media_port[media_info->media_count]); if (g_ascii_isdigit(media_info->media_port[media_info->media_count][0])) { PROTO_ITEM_SET_HIDDEN(it); proto_tree_add_uint(sdp_media_tree, hf_media_port, tvb, offset, tokenlen, @@ -955,16 +941,12 @@ dissect_sdp_media(tvbuff_t *tvb, proto_item *ti, return; /* Save port protocol */ - media_info->media_proto[media_info->media_count] = (char*)tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tokenlen, ENC_UTF_8|ENC_NA); - + proto_tree_add_item_ret_string(sdp_media_tree, hf_media_proto, tvb, offset, tokenlen, + ENC_UTF_8|ENC_NA, wmem_packet_scope(), &media_info->media_proto[media_info->media_count]); DPRINT(("parsed media_proto=%s, for media_count=%d", media_info->media_proto[media_info->media_count], media_info->media_count)); - /* XXX Remember Protocol */ - proto_tree_add_item(sdp_media_tree, hf_media_proto, tvb, offset, tokenlen, - ENC_UTF_8|ENC_NA); - do { offset = next_offset + 1; tokenlen = find_next_optional_token_in_line(tvb, sdp_media_tree, @@ -1245,7 +1227,7 @@ decode_sdp_fmtp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset takes place. A comma is used to separate any pair of parameter sets in the list. */ - gchar *data_p = NULL; + const guint8 *data_p = NULL; gint comma_offset; @@ -1258,8 +1240,7 @@ decode_sdp_fmtp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset tokenlen = end_offset - offset; } - data_p = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tokenlen, ENC_UTF_8|ENC_NA); - proto_tree_add_string(tree, hf_sdp_nal_unit_1_string, tvb, offset, tokenlen, data_p); + proto_tree_add_item_ret_string(tree, hf_sdp_nal_unit_1_string, tvb, offset, tokenlen, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &data_p); data_tvb = base64_to_tvb(tvb, data_p); add_new_data_source(pinfo, data_tvb, "h264 prop-parameter-sets"); @@ -1276,8 +1257,7 @@ decode_sdp_fmtp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset /* Second NAL unit */ offset = comma_offset +1; tokenlen = end_offset - offset; - data_p = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tokenlen, ENC_UTF_8|ENC_NA); - proto_tree_add_string(tree, hf_sdp_nal_unit_2_string, tvb, offset, tokenlen, data_p); + proto_tree_add_item_ret_string(tree, hf_sdp_nal_unit_2_string, tvb, offset, tokenlen, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &data_p); data_tvb = base64_to_tvb(tvb, data_p); add_new_data_source(pinfo, data_tvb, "h264 prop-parameter-sets 2"); dissect_h264_nal_unit(data_tvb, pinfo, tree); @@ -1324,20 +1304,20 @@ static gint find_sdp_media_attribute_names(tvbuff_t *tvb, int offset, guint len) static void dissect_sdp_media_attribute(tvbuff_t *tvb, packet_info *pinfo, proto_item * ti, int length, transport_info_t *transport_info, disposable_media_info_t *media_info) { - proto_tree *sdp_media_attribute_tree, *parameter_item; - proto_item *fmtp_item, *media_format_item, *parameter_tree; - proto_tree *fmtp_tree; - gint offset, next_offset, tokenlen, n, colon_offset; - /*??guint8 *field_name;*/ - guint8 *payload_type; - guint8 *attribute_value; - guint8 pt; - gint sdp_media_attrbute_code; - const char *msrp_res = "msrp://"; - const char *h324ext_h223lcparm = "h324ext/h223lcparm"; - gboolean has_more_pars = TRUE; - tvbuff_t *h245_tvb; - guint8 master_key_length = 0, master_salt_length = 0; + proto_tree *sdp_media_attribute_tree, *parameter_item; + proto_item *fmtp_item, *media_format_item, *parameter_tree; + proto_tree *fmtp_tree; + gint offset, next_offset, tokenlen, n, colon_offset; + /*??guint8 *field_name;*/ + const guint8 *payload_type; + guint8 *attribute_value; + guint8 pt; + gint sdp_media_attrbute_code; + const char *msrp_res = "msrp://"; + const char *h324ext_h223lcparm = "h324ext/h223lcparm"; + gboolean has_more_pars = TRUE; + tvbuff_t *h245_tvb; + guint8 master_key_length = 0, master_salt_length = 0; offset = 0; @@ -1381,10 +1361,8 @@ static void dissect_sdp_media_attribute(tvbuff_t *tvb, packet_info *pinfo, proto tokenlen = next_offset - offset; - proto_tree_add_item(sdp_media_attribute_tree, hf_media_format, tvb, - offset, tokenlen, ENC_UTF_8|ENC_NA); - - payload_type = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tokenlen, ENC_UTF_8|ENC_NA); + proto_tree_add_item_ret_string(sdp_media_attribute_tree, hf_media_format, tvb, + offset, tokenlen, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &payload_type); offset = next_offset + 1; diff --git a/epan/dissectors/packet-sip.c b/epan/dissectors/packet-sip.c index 8e4591e7c0..267e351d2a 100644 --- a/epan/dissectors/packet-sip.c +++ b/epan/dissectors/packet-sip.c @@ -2011,7 +2011,7 @@ static void dissect_sip_reason_header(tvbuff_t *tvb, proto_tree *tree, gint start_offset, gint line_end_offset){ gint current_offset, semi_colon_offset, length; - gchar *param_name = NULL; + const guint8 *param_name = NULL; guint cause_value; proto_item* ti; @@ -2031,9 +2031,8 @@ dissect_sip_reason_header(tvbuff_t *tvb, proto_tree *tree, gint start_offset, gi return; length = semi_colon_offset - current_offset; - proto_tree_add_item(tree, hf_sip_reason_protocols, tvb, start_offset, length, ENC_UTF_8|ENC_NA); + proto_tree_add_item_ret_string(tree, hf_sip_reason_protocols, tvb, start_offset, length, ENC_UTF_8|ENC_NA, wmem_packet_scope(), ¶m_name); - param_name = tvb_get_string_enc(wmem_packet_scope(), tvb, start_offset, length, ENC_UTF_8|ENC_NA); if (g_ascii_strcasecmp(param_name, "Q.850") == 0){ current_offset = tvb_find_guint8(tvb, semi_colon_offset, line_end_offset-semi_colon_offset, '=')+1; length = line_end_offset - current_offset; diff --git a/epan/dissectors/packet-smb-pipe.c b/epan/dissectors/packet-smb-pipe.c index 2b7f298d88..9762d2eace 100644 --- a/epan/dissectors/packet-smb-pipe.c +++ b/epan/dissectors/packet-smb-pipe.c @@ -793,11 +793,8 @@ static const item_t lm_params_resp_netshareenum[] = { static proto_item * netshareenum_share_entry(tvbuff_t *tvb, proto_tree *tree, int offset) { - if (tree) { - return proto_tree_add_string(tree, hf_share, tvb, offset, -1, + return proto_tree_add_string(tree, hf_share, tvb, offset, -1, tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 13, ENC_ASCII)); - } else - return NULL; } static const item_t lm_null[] = { @@ -993,11 +990,8 @@ static const item_t lm_params_req_netserverenum2[] = { static proto_item * netserverenum2_server_entry(tvbuff_t *tvb, proto_tree *tree, int offset) { - if (tree) { - return proto_tree_add_string(tree, hf_server, tvb, offset, -1, + return proto_tree_add_string(tree, hf_server, tvb, offset, -1, tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 16, ENC_ASCII)); - } else - return NULL; } static const item_t lm_params_resp_netserverenum2[] = { diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c index 9ce5fb651e..e64fec5ee9 100644 --- a/epan/dissectors/packet-smb.c +++ b/epan/dissectors/packet-smb.c @@ -7499,11 +7499,11 @@ dissect_connect_flags(tvbuff_t *tvb, proto_tree *parent_tree, int offset) static int dissect_tree_connect_andx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si) { - guint8 wc, cmd = 0xff; - guint16 bc; - guint16 andxoffset = 0, pwlen = 0; - int an_len; - const char *an; + guint8 wc, cmd = 0xff; + guint16 bc; + guint16 andxoffset = 0, pwlen = 0; + int an_len; + const guint8 *an; DISSECTOR_ASSERT(si); @@ -7573,9 +7573,8 @@ dissect_tree_connect_andx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree /* XXX - what if this runs past bc? */ an_len = tvb_strsize(tvb, offset); CHECK_BYTE_COUNT(an_len); - an = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, an_len, ENC_ASCII); - proto_tree_add_string(tree, hf_smb_service, tvb, - offset, an_len, an); + proto_tree_add_item_ret_string(tree, hf_smb_service, tvb, + offset, an_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &an); COUNT_BYTES(an_len); END_OF_SMB @@ -7594,11 +7593,11 @@ dissect_tree_connect_andx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree static int dissect_tree_connect_andx_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, proto_tree *smb_tree, smb_info_t *si) { - guint8 wc, cmd = 0xff; - guint16 andxoffset = 0; - guint16 bc; - int an_len; - const char *an; + guint8 wc, cmd = 0xff; + guint16 andxoffset = 0; + guint16 bc; + int an_len; + const guint8 *an; DISSECTOR_ASSERT(si); @@ -7680,9 +7679,8 @@ dissect_tree_connect_andx_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree /* XXX - what if this runs past bc? */ an_len = tvb_strsize(tvb, offset); CHECK_BYTE_COUNT(an_len); - an = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, an_len, ENC_ASCII); - proto_tree_add_string(tree, hf_smb_service, tvb, - offset, an_len, an); + proto_tree_add_item_ret_string(tree, hf_smb_service, tvb, + offset, an_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &an); COUNT_BYTES(an_len); /* Now when we know the service type, store it so that we know it for later commands down diff --git a/epan/dissectors/packet-stun.c b/epan/dissectors/packet-stun.c index cf2c19d5bf..65ab0dafaf 100644 --- a/epan/dissectors/packet-stun.c +++ b/epan/dissectors/packet-stun.c @@ -874,11 +874,14 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole /* Deprecated STUN RFC3489 attributes */ case PASSWORD: - proto_tree_add_item(att_tree, hf_stun_att_password, tvb, offset, att_length, ENC_UTF_8|ENC_NA); - proto_item_append_text(att_tree, " (Deprecated): %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, att_length, ENC_UTF_8|ENC_NA)); + { + const guint8* dep_password; + proto_tree_add_item_ret_string(att_tree, hf_stun_att_password, tvb, offset, att_length, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &dep_password); + proto_item_append_text(att_tree, " (Deprecated): %s", dep_password); if (att_length % 4 != 0) proto_tree_add_uint(att_tree, hf_stun_att_padding, tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4)); + } break; case MAPPED_ADDRESS: @@ -934,10 +937,9 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole case USERNAME: { - const gchar *user_name_str; + const guint8 *user_name_str; - proto_tree_add_item(att_tree, hf_stun_att_username, tvb, offset, att_length, ENC_UTF_8|ENC_NA); - user_name_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, att_length, ENC_UTF_8 | ENC_NA); + proto_tree_add_item_ret_string(att_tree, hf_stun_att_username, tvb, offset, att_length, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &user_name_str); proto_item_append_text(att_tree, ": %s", user_name_str); col_append_fstr( pinfo->cinfo, COL_INFO, @@ -983,16 +985,12 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole } if (att_length < 5) break; - proto_tree_add_item(att_tree, hf_stun_att_error_reason, tvb, offset + 4, att_length - 4, ENC_UTF_8 | ENC_NA); { - const gchar *error_reas_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 4, att_length - 4, ENC_UTF_8 | ENC_NA); + const guint8 *error_reas_str; + proto_tree_add_item_ret_string(att_tree, hf_stun_att_error_reason, tvb, offset + 4, att_length - 4, ENC_UTF_8 | ENC_NA, wmem_packet_scope(), &error_reas_str); - proto_item_append_text(att_tree, ": %s", error_reas_str); - col_append_fstr( - pinfo->cinfo, COL_INFO, - " %s", - error_reas_str - ); + proto_item_append_text(att_tree, ": %s", error_reas_str); + col_append_fstr(pinfo->cinfo, COL_INFO, " %s", error_reas_str); } if (att_length % 4 != 0) @@ -1008,28 +1006,24 @@ dissect_stun_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboole case REALM: { - const gchar *realm_str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, att_length, ENC_UTF_8 | ENC_NA); - proto_tree_add_item(att_tree, hf_stun_att_realm, tvb, offset, att_length, ENC_UTF_8|ENC_NA); + const guint8 *realm_str; + proto_tree_add_item_ret_string(att_tree, hf_stun_att_realm, tvb, offset, att_length, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &realm_str); proto_item_append_text(att_tree, ": %s", realm_str); - col_append_fstr( - pinfo->cinfo, COL_INFO, - " realm: %s", - realm_str - ); + col_append_fstr(pinfo->cinfo, COL_INFO, " realm: %s", realm_str); if (att_length % 4 != 0) proto_tree_add_uint(att_tree, hf_stun_att_padding, tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4)); break; } case NONCE: - proto_tree_add_item(att_tree, hf_stun_att_nonce, tvb, offset, att_length, ENC_UTF_8|ENC_NA); - proto_item_append_text(att_tree, ": %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, att_length, ENC_UTF_8|ENC_NA)); - col_append_str( - pinfo->cinfo, COL_INFO, - " with nonce" - ); + { + const guint8 *nonce_str; + proto_tree_add_item_ret_string(att_tree, hf_stun_att_nonce, tvb, offset, att_length, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &nonce_str); + proto_item_append_text(att_tree, ": %s", nonce_str); + col_append_str(pinfo->cinfo, COL_INFO, " with nonce"); if (att_length % 4 != 0) proto_tree_add_uint(att_tree, hf_stun_att_padding, tvb, offset+att_length, 4-(att_length % 4), 4-(att_length % 4)); break; + } case XOR_MAPPED_ADDRESS: case XOR_PEER_ADDRESS: diff --git a/epan/dissectors/packet-tcpros.c b/epan/dissectors/packet-tcpros.c index 24a2535f01..ed66fc40fe 100644 --- a/epan/dissectors/packet-tcpros.c +++ b/epan/dissectors/packet-tcpros.c @@ -99,11 +99,12 @@ dissect_ros_connection_header_field(tvbuff_t *tvb, proto_tree *tree, packet_info /** If we find a separator, then split field name and value */ if( sep > 0 ) { + const guint8* field; field_tree = proto_item_add_subtree(ti, ett_tcpros); - proto_tree_add_item(field_tree, hf_tcpros_connection_header_field_name, tvb, offset, sep, ENC_UTF_8|ENC_NA); + proto_tree_add_item_ret_string(field_tree, hf_tcpros_connection_header_field_name, tvb, offset, sep, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &field); proto_tree_add_item(field_tree, hf_tcpros_connection_header_field_value, tvb, offset+sep+1, fLen - sep - 1, ENC_UTF_8|ENC_NA); - col_append_str(pinfo->cinfo, COL_INFO, tvb_get_string_enc(wmem_packet_scope(), tvb, offset, sep, ENC_UTF_8)); + col_append_str(pinfo->cinfo, COL_INFO, field); } ret = fLen + SIZE_OF_LENGTH_FIELD; } @@ -188,6 +189,7 @@ dissect_ros_message_header(tvbuff_t *tvb, proto_tree *root_tree, packet_info *pi guint32 frame_id_len; guint32 seq; guint header_len; + const guint8* frame_str; frame_id_len = tvb_get_letohl(tvb, offset + consumed_len + SIZE_OF_LENGTH_FIELD + SIZE_OF_LENGTH_STAMP); @@ -213,8 +215,8 @@ dissect_ros_message_header(tvbuff_t *tvb, proto_tree *root_tree, packet_info *pi proto_tree_add_item(sub_tree, hf_tcpros_message_header_frame_length, tvb, offset + consumed_len, SIZE_OF_LENGTH_FIELD, ENC_LITTLE_ENDIAN); consumed_len += SIZE_OF_LENGTH_FIELD; - proto_tree_add_item(sub_tree, hf_tcpros_message_header_frame_value, tvb, offset + consumed_len, frame_id_len, ENC_UTF_8|ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, "Frame: '%s' ", tvb_get_string_enc(wmem_packet_scope(), tvb, offset + consumed_len, frame_id_len, ENC_UTF_8) ); + proto_tree_add_item_ret_string(sub_tree, hf_tcpros_message_header_frame_value, tvb, offset + consumed_len, frame_id_len, ENC_UTF_8|ENC_NA, wmem_packet_scope(), &frame_str); + col_append_fstr(pinfo->cinfo, COL_INFO, "Frame: '%s' ", frame_str); consumed_len += frame_id_len; return consumed_len; diff --git a/epan/dissectors/packet-tftp.c b/epan/dissectors/packet-tftp.c index fcaa58401f..2db40e701e 100644 --- a/epan/dissectors/packet-tftp.c +++ b/epan/dissectors/packet-tftp.c @@ -53,17 +53,17 @@ void proto_register_tftp(void); /* Things we may want to remember for a whole conversation */ typedef struct _tftp_conv_info_t { - guint16 blocksize; - gchar *source_file, *destination_file; + guint16 blocksize; + const guint8 *source_file, *destination_file; /* Sequence analysis */ - guint next_block_num; - gboolean blocks_missing; + guint next_block_num; + gboolean blocks_missing; /* When exporting file object, build up list of data blocks here */ - guint next_tap_block_num; - GSList *block_list; - guint file_length; + guint next_tap_block_num; + GSList *block_list; + guint file_length; } tftp_conv_info_t; @@ -251,10 +251,9 @@ static void dissect_tftp_message(tftp_conv_info_t *tftp_info, case TFTP_RRQ: i1 = tvb_strsize(tvb, offset); - proto_tree_add_item(tftp_tree, hf_tftp_source_file, - tvb, offset, i1, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(tftp_tree, hf_tftp_source_file, + tvb, offset, i1, ENC_ASCII|ENC_NA, wmem_file_scope(), &tftp_info->source_file); - tftp_info->source_file = tvb_get_string_enc(wmem_file_scope(), tvb, offset, i1, ENC_ASCII); /* we either have a source file name (for read requests) or a destination file name (for write requests) when we set one of the names, we clear the other */ @@ -280,11 +279,9 @@ static void dissect_tftp_message(tftp_conv_info_t *tftp_info, case TFTP_WRQ: i1 = tvb_strsize(tvb, offset); - proto_tree_add_item(tftp_tree, hf_tftp_destination_file, - tvb, offset, i1, ENC_ASCII|ENC_NA); + proto_tree_add_item_ret_string(tftp_tree, hf_tftp_destination_file, + tvb, offset, i1, ENC_ASCII|ENC_NA, wmem_file_scope(), &tftp_info->destination_file); - tftp_info->destination_file = - tvb_get_string_enc(wmem_file_scope(), tvb, offset, i1, ENC_ASCII); tftp_info->source_file = NULL; /* see above */ col_append_fstr(pinfo->cinfo, COL_INFO, ", File: %s", diff --git a/epan/dissectors/packet-tnef.c b/epan/dissectors/packet-tnef.c index 0265b76462..b57a2627c9 100644 --- a/epan/dissectors/packet-tnef.c +++ b/epan/dissectors/packet-tnef.c @@ -595,8 +595,11 @@ static int dissect_tnef(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi break; case ATP_STRING: - proto_tree_add_item(attr_tree, hf_tnef_attribute_string, tvb, offset, length, ENC_ASCII|ENC_NA); - proto_item_append_text(attr_item, " %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII)); + { + const guint8* atp; + proto_tree_add_item_ret_string(attr_tree, hf_tnef_attribute_string, tvb, offset, length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &atp); + proto_item_append_text(attr_item, " %s", atp); + } break; default: proto_tree_add_item(attr_tree, hf_tnef_attribute_value, tvb, offset, length, ENC_NA); diff --git a/epan/dissectors/packet-ubertooth.c b/epan/dissectors/packet-ubertooth.c index ef5f2c19d9..546e7f9d6b 100644 --- a/epan/dissectors/packet-ubertooth.c +++ b/epan/dissectors/packet-ubertooth.c @@ -1908,6 +1908,8 @@ dissect_ubertooth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 33: /* Get Firmware Revision Number */ + { + const guint8* firmware; proto_tree_add_item(main_tree, hf_reserved, tvb, offset, 2, ENC_NA); offset += 2; @@ -1915,10 +1917,10 @@ dissect_ubertooth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat length = tvb_get_guint8(tvb, offset); offset += 1; - proto_tree_add_item(main_tree, hf_firmware_revision, tvb, offset, length, ENC_NA | ENC_ASCII); - col_append_fstr(pinfo->cinfo, COL_INFO, " = %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII)); + proto_tree_add_item_ret_string(main_tree, hf_firmware_revision, tvb, offset, length, ENC_NA | ENC_ASCII, wmem_packet_scope(), &firmware); + col_append_fstr(pinfo->cinfo, COL_INFO, " = %s", firmware); offset += length; - + } break; case 35: /* Get Hardware Board ID */ proto_tree_add_item(main_tree, hf_board_id, tvb, offset, 1, ENC_NA); @@ -1985,14 +1987,16 @@ dissect_ubertooth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 55: /* Get Compile Info */ + { + const guint8* compile; proto_tree_add_item(main_tree, hf_length, tvb, offset, 1, ENC_NA); length = tvb_get_guint8(tvb, offset); offset += 1; - proto_tree_add_item(main_tree, hf_firmware_compile_info, tvb, offset, length, ENC_NA | ENC_ASCII); - col_append_fstr(pinfo->cinfo, COL_INFO, " = %s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset, length, ENC_ASCII)); + proto_tree_add_item_ret_string(main_tree, hf_firmware_compile_info, tvb, offset, length, ENC_NA | ENC_ASCII, wmem_packet_scope(), &compile); + col_append_fstr(pinfo->cinfo, COL_INFO, " = %s", compile); offset += length; - + } break; } diff --git a/epan/dissectors/packet-uma.c b/epan/dissectors/packet-uma.c index a5233cabc8..14e60e48a4 100644 --- a/epan/dissectors/packet-uma.c +++ b/epan/dissectors/packet-uma.c @@ -872,7 +872,7 @@ dissect_uma_IE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) guint8 octet; proto_item *urr_ie_item; proto_tree *urr_ie_tree; - char *string; + const guint8 *string; guint16 GPRS_user_data_transport_UDP_port,UNC_tcp_port,RTP_UDP_port,RTCP_UDP_port; guint32 udr; conversation_t *conversation; @@ -1444,8 +1444,7 @@ dissect_uma_IE(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) case 98: /* UNC Fully Qualified Domain/Host Name */ if ( ie_len > 0){ - string = (gchar*)tvb_get_string_enc(wmem_packet_scope(), tvb, ie_offset, ie_len, ENC_ASCII); - proto_tree_add_string(urr_ie_tree, hf_uma_unc_FQDN, tvb, ie_offset, ie_len, string); + proto_tree_add_item_ret_string(urr_ie_tree, hf_uma_unc_FQDN, tvb, ie_offset, ie_len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &string); }else{ proto_tree_add_expert(urr_ie_tree, pinfo, &ei_uma_fqdn_not_present, tvb, offset, 1); } diff --git a/epan/dissectors/packet-v5ua.c b/epan/dissectors/packet-v5ua.c index 9924bf3e9c..a1be56e9b0 100644 --- a/epan/dissectors/packet-v5ua.c +++ b/epan/dissectors/packet-v5ua.c @@ -190,12 +190,12 @@ static void dissect_text_interface_identifier_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item) { guint16 if_id_length; + const guint8* str; if_id_length = tvb_get_ntohs(parameter_tvb, TEXT_IF_ID_LENGTH_OFFSET) - TEXT_IF_ID_HEADER_LENGTH; - proto_tree_add_item(parameter_tree, hf_text_if_id, parameter_tvb, TEXT_IF_ID_VALUE_OFFSET, if_id_length, ENC_ASCII|ENC_NA); - proto_item_append_text(parameter_item, " (0x%.*s)", if_id_length, - tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, TEXT_IF_ID_VALUE_OFFSET, if_id_length, ENC_ASCII)); + proto_tree_add_item_ret_string(parameter_tree, hf_text_if_id, parameter_tvb, TEXT_IF_ID_VALUE_OFFSET, if_id_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(parameter_item, " (0x%.*s)", if_id_length, str); } /*----------------------Text Interface Identifier (RFC)------------------------*/ @@ -468,20 +468,20 @@ dissect_draft_tei_status_parameter(tvbuff_t *parameter_tvb, proto_tree *paramete static void dissect_asp_msg_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item) { + const guint8* str; guint16 adaptation_layer_id_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET); - proto_tree_add_item(parameter_tree, hf_adaptation_layer_id, parameter_tvb, PARAMETER_VALUE_OFFSET, adaptation_layer_id_length, ENC_ASCII|ENC_NA); - proto_item_append_text(parameter_item, " (%.*s)", adaptation_layer_id_length, - tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, PARAMETER_VALUE_OFFSET, adaptation_layer_id_length, ENC_ASCII)); + proto_tree_add_item_ret_string(parameter_tree, hf_adaptation_layer_id, parameter_tvb, PARAMETER_VALUE_OFFSET, adaptation_layer_id_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(parameter_item, " (%.*s)", adaptation_layer_id_length, str); } static void dissect_scn_protocol_id_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item) { + const guint8* str; guint16 id_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET); - proto_tree_add_item(parameter_tree, hf_scn_protocol_id, parameter_tvb, PARAMETER_VALUE_OFFSET, id_length, ENC_ASCII|ENC_NA); - proto_item_append_text(parameter_item, " (%.*s)", id_length, - tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, PARAMETER_VALUE_OFFSET, id_length, ENC_ASCII)); + proto_tree_add_item_ret_string(parameter_tree, hf_scn_protocol_id, parameter_tvb, PARAMETER_VALUE_OFFSET, id_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(parameter_item, " (%.*s)", id_length, str); } /*----------------------ASP (Draft)--------------------------------------------*/ @@ -766,14 +766,14 @@ static void dissect_info_string_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item) { guint16 info_string_length; + const guint8* str; info_string_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET); if(iua_version == DRAFT) info_string_length += 4; if(info_string_length > 4){ info_string_length -= PARAMETER_HEADER_LENGTH; - proto_tree_add_item(parameter_tree, hf_info_string, parameter_tvb, INFO_STRING_OFFSET, info_string_length, ENC_ASCII|ENC_NA); - proto_item_append_text(parameter_item, " (%.*s)", info_string_length, - tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, INFO_STRING_OFFSET, info_string_length, ENC_ASCII)); + proto_tree_add_item_ret_string(parameter_tree, hf_info_string, parameter_tvb, INFO_STRING_OFFSET, info_string_length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &str); + proto_item_append_text(parameter_item, " (%.*s)", info_string_length, str); } } diff --git a/epan/dissectors/packet-vnc.c b/epan/dissectors/packet-vnc.c index a5c8480b58..e65ada4012 100644 --- a/epan/dissectors/packet-vnc.c +++ b/epan/dissectors/packet-vnc.c @@ -982,13 +982,11 @@ dissect_vnc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) static gint process_vendor(proto_tree *tree, gint hfindex, tvbuff_t *tvb, gint offset) { - gchar *vendor; + const guint8 *vendor; proto_item *ti; if (tree) { - vendor = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 4, ENC_ASCII); - - ti = proto_tree_add_string(tree, hfindex, tvb, offset, 4, vendor); + ti = proto_tree_add_item_ret_string(tree, hfindex, tvb, offset, 4, ENC_ASCII|ENC_NA, wmem_packet_scope(), &vendor); if(g_ascii_strcasecmp(vendor, "STDV") == 0) proto_item_append_text(ti, " (Standard VNC vendor)"); @@ -1012,15 +1010,13 @@ process_tight_capabilities(proto_tree *tree, /* See vnc_unixsrc/include/rfbproto.h:rfbCapabilityInfo */ for (i = 0; i < num_capabilities; i++) { - char *name; proto_tree_add_item(tree, type_index, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; offset = process_vendor(tree, vendor_index, tvb, offset); - name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 8, ENC_ASCII); - proto_tree_add_string(tree, name_index, tvb, offset, 8, name); + proto_tree_add_item(tree, name_index, tvb, offset, 8, ENC_ASCII|ENC_NA); offset += 8; } @@ -1286,7 +1282,7 @@ vnc_startup_messages(tvbuff_t *tvb, packet_info *pinfo, gint offset, { int i; - guint8 *vendor, *signature; + const guint8 *vendor, *signature; for (i = 0; i < 1; i++) { auth_code = tvb_get_ntohl(tvb, offset); auth_item = proto_tree_add_item(tree, hf_vnc_tight_auth_code, tvb, offset, 4, ENC_BIG_ENDIAN); @@ -1294,8 +1290,7 @@ vnc_startup_messages(tvbuff_t *tvb, packet_info *pinfo, gint offset, vendor = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 4, ENC_ASCII); process_vendor(tree, hf_vnc_tight_server_vendor, tvb, offset); offset += 4; - signature = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, 8, ENC_ASCII); - proto_tree_add_string(tree, hf_vnc_tight_signature, tvb, offset, 8, signature); + proto_tree_add_item_ret_string(tree, hf_vnc_tight_signature, tvb, offset, 8, ENC_ASCII|ENC_NA, wmem_packet_scope(), &signature); offset += 8; switch(auth_code) { -- cgit v1.2.3