forked from osmocom/wireshark
Ensure to have a valid string pointer when writing OS SHB option
Change-Id: Ib0b6dcdf1700e88383d30bf43739312fce10e1c7 Reviewed-on: https://code.wireshark.org/review/16696 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
parent
3a3bf8926e
commit
4713ce4476
|
@ -465,6 +465,7 @@ file_import_open(text_import_info_t *info)
|
|||
wtapng_if_descr_mandatory_t *int_data_mand;
|
||||
GString *os_info_str;
|
||||
gsize opt_len;
|
||||
gchar *opt_str;
|
||||
|
||||
/* Create data for SHB */
|
||||
os_info_str = g_string_new("");
|
||||
|
@ -480,7 +481,11 @@ file_import_open(text_import_info_t *info)
|
|||
* this section.
|
||||
*/
|
||||
opt_len = os_info_str->len;
|
||||
wtap_block_add_string_option(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, TRUE), opt_len);
|
||||
opt_str = g_string_free(os_info_str, FALSE);
|
||||
if (opt_str) {
|
||||
wtap_block_add_string_option(shb_hdr, OPT_SHB_OS, opt_str, opt_len);
|
||||
g_free(opt_str);
|
||||
}
|
||||
/*
|
||||
* UTF-8 string containing the name of the application used to create
|
||||
* this section.
|
||||
|
|
|
@ -109,6 +109,7 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
|
|||
wtapng_if_descr_mandatory_t *int_data_mand;
|
||||
GString *os_info_str;
|
||||
gsize opt_len;
|
||||
gchar *opt_str;
|
||||
|
||||
/* Create data for SHB */
|
||||
os_info_str = g_string_new("");
|
||||
|
@ -125,7 +126,11 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
|
|||
* this section.
|
||||
*/
|
||||
opt_len = os_info_str->len;
|
||||
wtap_block_add_string_option(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, TRUE), opt_len);
|
||||
opt_str = g_string_free(os_info_str, FALSE);
|
||||
if (opt_str) {
|
||||
wtap_block_add_string_option(shb_hdr, OPT_SHB_OS, opt_str, opt_len);
|
||||
g_free(opt_str);
|
||||
}
|
||||
/*
|
||||
* UTF-8 string containing the name of the application used to create
|
||||
* this section.
|
||||
|
|
|
@ -372,6 +372,7 @@ create_shb_header(const merge_in_file_t *in_files, const guint in_file_count,
|
|||
char* shb_comment = NULL;
|
||||
wtapng_mandatory_section_t* shb_data;
|
||||
gsize opt_len;
|
||||
gchar *opt_str;
|
||||
|
||||
shb_hdrs = wtap_file_get_shb_for_new_file(in_files[0].wth);
|
||||
shb_hdr = g_array_index(shb_hdrs, wtap_block_t, 0);
|
||||
|
@ -412,8 +413,12 @@ create_shb_header(const merge_in_file_t *in_files, const guint in_file_count,
|
|||
*/
|
||||
wtap_block_remove_option(shb_hdr, OPT_SHB_HARDWARE);
|
||||
opt_len = os_info_str->len;
|
||||
wtap_block_set_string_option_value(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, FALSE), opt_len); /* UTF-8 string containing the name */
|
||||
/* of the operating system used to create this section. */
|
||||
opt_str = g_string_free(os_info_str, FALSE);
|
||||
if (opt_str) {
|
||||
wtap_block_set_string_option_value(shb_hdr, OPT_SHB_OS, opt_str, opt_len); /* UTF-8 string containing the name */
|
||||
/* of the operating system used to create this section. */
|
||||
g_free(opt_str);
|
||||
}
|
||||
wtap_block_set_string_option_value(shb_hdr, OPT_SHB_USERAPPL, (char*)app_name, app_name ? strlen(app_name): 0 ); /* NULL if not available, UTF-8 string containing the name */
|
||||
/* of the application used to create this section. */
|
||||
|
||||
|
|
|
@ -729,6 +729,7 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
|
|||
int name_str_len;
|
||||
char name_str[64];
|
||||
gsize opt_len;
|
||||
gchar *opt_str;
|
||||
/* Info to build exported_pdu tags*/
|
||||
exported_pdu_info_t exported_pdu_info;
|
||||
|
||||
|
@ -762,7 +763,11 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
|
|||
* this section.
|
||||
*/
|
||||
opt_len = os_info_str->len;
|
||||
wtap_block_add_string_option(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, TRUE), opt_len);
|
||||
opt_str = g_string_free(os_info_str, FALSE);
|
||||
if (opt_str) {
|
||||
wtap_block_add_string_option(shb_hdr, OPT_SHB_OS, opt_str, opt_len);
|
||||
g_free(opt_str);
|
||||
}
|
||||
|
||||
/*
|
||||
* UTF-8 string containing the name of the application used to create
|
||||
|
|
Loading…
Reference in New Issue