aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-01-03 14:35:01 -0800
committerGuy Harris <guy@alum.mit.edu>2015-01-03 22:35:27 +0000
commit938485436e7b7c647323a147c8ea1abc33e07564 (patch)
tree2c0ce27222b3a8f08c950b1d8655f04557286d21
parent9df73862fbb2ad7eecdad335714fa6a0487c1973 (diff)
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>
-rw-r--r--tshark.c7
-rw-r--r--ui/gtk/file_import_dlg.c6
-rw-r--r--ui/tap_export_pdu.c6
3 files changed, 13 insertions, 6 deletions
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;
}
diff --git a/ui/gtk/file_import_dlg.c b/ui/gtk/file_import_dlg.c
index f861f7c81f..69ae7b6833 100644
--- a/ui/gtk/file_import_dlg.c
+++ b/ui/gtk/file_import_dlg.c
@@ -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);
}
diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c
index 6744a32d96..48c112cec1 100644
--- a/ui/tap_export_pdu.c
+++ b/ui/tap_export_pdu.c
@@ -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