From 938485436e7b7c647323a147c8ea1abc33e07564 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 3 Jan 2015 14:35:01 -0800 Subject: 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 --- tshark.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tshark.c') diff --git a/tshark.c b/tshark.c index 2fcda03bcc..54a70516c8 100644 --- a/tshark.c +++ b/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; } -- cgit v1.2.3