From 36e13a4c55a5080ae504691c8062f359c3c8668f Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Wed, 23 Oct 2013 15:31:48 +0000 Subject: 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 --- capture.c | 7 +++++++ capture_opts.c | 1 + capture_opts.h | 1 + ui/gtk/capture_dlg.c | 1 + 4 files changed, 10 insertions(+) diff --git a/capture.c b/capture.c index 76882f086a..2131ad683c 100644 --- a/capture.c +++ b/capture.c @@ -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); diff --git a/capture_opts.c b/capture_opts.c index 2e77bc1e44..53b6253346 100644 --- a/capture_opts.c +++ b/capture_opts.c @@ -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; diff --git a/capture_opts.h b/capture_opts.h index 05db1dec1b..f99dac62c1 100644 --- a/capture_opts.h +++ b/capture_opts.h @@ -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 */ diff --git a/ui/gtk/capture_dlg.c b/ui/gtk/capture_dlg.c index 9f2616f734..34845c3827 100644 --- a/ui/gtk/capture_dlg.c +++ b/ui/gtk/capture_dlg.c @@ -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 */ -- cgit v1.2.1