Bugfix "Restart the running live capture" when using multiple files makes a long filename. Bug 2274 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2274)

Yes this solution leaks memory, but I think the handful of bytes leaked is worth fixing this nuisance.  Won't backport until leak is fixed though.

svn path=/trunk/; revision=52793
This commit is contained in:
Michael Mann 2013-10-23 15:31:48 +00:00
parent be86384b34
commit 36e13a4c55
4 changed files with 10 additions and 0 deletions

View File

@ -646,6 +646,13 @@ capture_input_closed(capture_session *cap_session, gchar *msg)
ws_unlink(capture_opts->save_file);
/* If we have a ring buffer, the original save file has been overwritten
with the "ring filename". Restore it before starting again */
if ((capture_opts->multi_files_on) && (capture_opts->orig_save_file != NULL)) {
g_free(capture_opts->save_file);
capture_opts->save_file = g_strdup(capture_opts->orig_save_file);
}
/* if it was a tempfile, throw away the old filename (so it will become a tempfile again) */
if(cf_is_tempfile((capture_file *)cap_session->cf)) {
g_free(capture_opts->save_file);

View File

@ -97,6 +97,7 @@ capture_opts_init(capture_options *capture_opts)
capture_opts->show_info = TRUE;
capture_opts->quit_after_cap = getenv("WIRESHARK_QUIT_AFTER_CAPTURE") ? TRUE : FALSE;
capture_opts->restart = FALSE;
capture_opts->orig_save_file = NULL;
capture_opts->multi_files_on = FALSE;
capture_opts->has_file_duration = FALSE;

View File

@ -186,6 +186,7 @@ typedef struct capture_options_tag {
gboolean show_info; /**< show the info dialog */
gboolean quit_after_cap; /**< Makes a "capture only mode". Implies -k */
gboolean restart; /**< restart after closing is done */
gchar *orig_save_file; /**< the original capture file name (saved for a restart) */
/* multiple files (and ringbuffer) */
gboolean multi_files_on; /**< TRUE if ring buffer in use */

View File

@ -5515,6 +5515,7 @@ capture_dlg_prep(gpointer parent_w) {
if (g_save_file && g_save_file[0]) {
/* User specified a file to which the capture should be written. */
global_capture_opts.save_file = g_strdup(g_save_file);
global_capture_opts.orig_save_file = g_strdup(g_save_file);
/* Save the directory name for future file dialogs. */
cf_name = g_strdup(g_save_file);
dirname = get_dirname(cf_name); /* Overwrites cf_name */