From 81d65ccec65c9bbe972fcb64933fc34d9679562c Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Thu, 19 May 2016 22:28:43 -0400 Subject: Add wtap_optionblock_set_option_string_format Also add a length parameter to wtap_optionblock_set_option_string Change-Id: I8c7bbc48aa96b5c2a91ab9a17980928d6894f1ee Reviewed-on: https://code.wireshark.org/review/15505 Reviewed-by: Anthony Coddington Reviewed-by: Michael Mann --- ui/tap_export_pdu.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'ui/tap_export_pdu.c') diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c index 3131973ed2..37706ba718 100644 --- a/ui/tap_export_pdu.c +++ b/ui/tap_export_pdu.c @@ -107,7 +107,7 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment) wtap_optionblock_t int_data; wtapng_if_descr_mandatory_t *int_data_mand; GString *os_info_str; - gchar *opt_comment, *wireshark_ver; + gsize opt_len; /* Create data for SHB */ os_info_str = g_string_new(""); @@ -116,22 +116,20 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment) shb_hdr = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION); /* options */ - opt_comment = comment; - wtap_optionblock_set_option_string(shb_hdr, OPT_COMMENT, opt_comment); - g_free(opt_comment); + wtap_optionblock_set_option_string(shb_hdr, OPT_COMMENT, comment, strlen(comment)); + g_free(comment); /* * UTF-8 string containing the name of the operating system used to create * this section. */ - wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, TRUE)); + opt_len = os_info_str->len; + wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, TRUE), opt_len); /* * UTF-8 string containing the name of the application used to create * this section. */ - wireshark_ver = g_strdup_printf("Wireshark %s", get_ws_vcs_version_info()); - wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_USERAPPL, wireshark_ver); - g_free(wireshark_ver); + wtap_optionblock_set_option_string_format(shb_hdr, OPT_SHB_USERAPPL, "Wireshark %s", get_ws_vcs_version_info()); /* Create fake IDB info */ idb_inf = g_new(wtapng_iface_descriptions_t,1); @@ -145,7 +143,7 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment) int_data_mand->link_type = wtap_wtap_encap_to_pcap_encap(WTAP_ENCAP_WIRESHARK_UPPER_PDU); int_data_mand->snap_len = WTAP_MAX_PACKET_SIZE; - wtap_optionblock_set_option_string(int_data, OPT_IDB_NAME, "Fake IF, PDU->Export"); + wtap_optionblock_set_option_string(int_data, OPT_IDB_NAME, "Fake IF, PDU->Export", strlen("Fake IF, PDU->Export")); wtap_optionblock_set_option_uint8(int_data, OPT_IDB_TSRESOL, 9); g_array_append_val(idb_inf->interface_data, int_data); -- cgit v1.2.1