forked from osmocom/wireshark
Use g_strdup_printf(), rather than a fixed-length buffer, for the app name.
Add some missing g_free()s while we're at it. Change-Id: Id38acc21d3c0b337e5d05baaf5ebbcd63699ff50 Reviewed-on: https://code.wireshark.org/review/6287 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
9df73862fb
commit
938485436e
7
tshark.c
7
tshark.c
|
@ -3094,7 +3094,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
guint tap_flags;
|
||||
wtapng_section_t *shb_hdr;
|
||||
wtapng_iface_descriptions_t *idb_inf;
|
||||
char appname[100];
|
||||
char *appname = NULL;
|
||||
struct wtap_pkthdr phdr;
|
||||
Buffer buf;
|
||||
epan_dissect_t *edt = NULL;
|
||||
|
@ -3124,7 +3124,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
}
|
||||
/* If we don't have an application name add Tshark */
|
||||
if (shb_hdr->shb_user_appl == NULL) {
|
||||
g_snprintf(appname, sizeof(appname), "TShark (Wireshark) %s", get_ws_vcs_version_info());
|
||||
appname = g_strdup_printf("TShark (Wireshark) %s", get_ws_vcs_version_info());
|
||||
shb_hdr->shb_user_appl = appname;
|
||||
}
|
||||
|
||||
|
@ -3337,6 +3337,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
}
|
||||
wtap_dump_close(pdh, &err);
|
||||
g_free(shb_hdr);
|
||||
g_free(appname);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
@ -3440,6 +3441,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
|
|||
}
|
||||
wtap_dump_close(pdh, &err);
|
||||
g_free(shb_hdr);
|
||||
g_free(appname);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
@ -3553,6 +3555,7 @@ out:
|
|||
|
||||
g_free(save_file_string);
|
||||
g_free(shb_hdr);
|
||||
g_free(appname);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -461,7 +461,7 @@ file_import_open(text_import_info_t *info)
|
|||
wtapng_iface_descriptions_t *idb_inf;
|
||||
wtapng_if_descr_t int_data;
|
||||
GString *os_info_str;
|
||||
char appname[100];
|
||||
char *appname;
|
||||
|
||||
/* Choose a random name for the temporary import buffer */
|
||||
import_file_fd = create_tempfile(&tmpname, "import");
|
||||
|
@ -471,7 +471,7 @@ file_import_open(text_import_info_t *info)
|
|||
os_info_str = g_string_new("");
|
||||
get_os_version_info(os_info_str);
|
||||
|
||||
g_snprintf(appname, sizeof(appname), "Wireshark %s", get_ws_vcs_version_info());
|
||||
appname = g_strdup_printf("Wireshark %s", get_ws_vcs_version_info());
|
||||
|
||||
shb_hdr = g_new(wtapng_section_t,1);
|
||||
shb_hdr->section_length = -1;
|
||||
|
@ -562,6 +562,8 @@ end:
|
|||
g_free(info->date_timestamp_format);
|
||||
g_free(info);
|
||||
g_free(capfile_name);
|
||||
g_free(shb_hdr);
|
||||
g_free(appname);
|
||||
window_destroy(file_import_dlg_w);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data)
|
|||
wtapng_iface_descriptions_t *idb_inf;
|
||||
wtapng_if_descr_t int_data;
|
||||
GString *os_info_str;
|
||||
char appname[100];
|
||||
char *appname;
|
||||
|
||||
/* Choose a random name for the temporary import buffer */
|
||||
import_file_fd = create_tempfile(&tmpname, "Wireshark_PDU_");
|
||||
|
@ -117,7 +117,7 @@ exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data)
|
|||
os_info_str = g_string_new("");
|
||||
get_os_version_info(os_info_str);
|
||||
|
||||
g_snprintf(appname, sizeof(appname), "Wireshark %s", get_ws_vcs_version_info());
|
||||
appname = g_strdup_printf("Wireshark %s", get_ws_vcs_version_info());
|
||||
|
||||
shb_hdr = g_new(wtapng_section_t,1);
|
||||
shb_hdr->section_length = -1;
|
||||
|
@ -200,6 +200,8 @@ exp_pdu_file_open(exp_pdu_t *exp_pdu_tap_data)
|
|||
|
||||
end:
|
||||
g_free(capfile_name);
|
||||
g_free(shb_hdr);
|
||||
g_free(appname);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
Loading…
Reference in New Issue