aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorEvan Huus <eapache@gmail.com>2013-04-13 18:24:06 +0000
committerEvan Huus <eapache@gmail.com>2013-04-13 18:24:06 +0000
commit882a1fe6f0e74b4e328654ec0845b30f71f8c2bd (patch)
tree265b4c2a73874fa47790dede452b21eeae9dd08e /file.c
parent07a024dc901e7c1aefc32a9f67d435c23a1d000c (diff)
Don't take the shortcut of moving/copying the existing file if we have a name
resolution block to write (which isn't necessarily in the existing file). Fixes at least part of https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8317 svn path=/trunk/; revision=48842
Diffstat (limited to 'file.c')
-rw-r--r--file.c58
1 files changed, 44 insertions, 14 deletions
diff --git a/file.c b/file.c
index 8dcb9fbcf2..dd78434431 100644
--- a/file.c
+++ b/file.c
@@ -75,6 +75,31 @@
#include "ui/progress_dlg.h"
#include "ui/ui_util.h"
+/* Needed for addrinfo */
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#ifdef HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#endif
+
+#ifdef HAVE_NETDB_H
+# include <netdb.h>
+#endif
+
+#ifdef HAVE_WINSOCK2_H
+# include <winsock2.h>
+#endif
+
+#if defined(_WIN32) && defined(INET6)
+# include <ws2tcpip.h>
+#endif
+
#ifdef HAVE_LIBPCAP
gboolean auto_scroll_live;
#endif
@@ -4307,30 +4332,35 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format,
gboolean compressed, gboolean discard_comments,
gboolean dont_reopen)
{
- gchar *fname_new = NULL;
- int err;
- gchar *err_info;
+ gchar *err_info;
+ gchar *fname_new = NULL;
+ wtap_dumper *pdh;
+ frame_data *fdata;
+ struct addrinfo *addrs;
+ guint framenum;
+ int err;
+#ifdef _WIN32
+ gchar *display_basename;
+#endif
enum {
SAVE_WITH_MOVE,
SAVE_WITH_COPY,
SAVE_WITH_WTAP
- } how_to_save;
- wtap_dumper *pdh;
+ } how_to_save;
save_callback_args_t callback_args;
-#ifdef _WIN32
- gchar *display_basename;
-#endif
- guint framenum;
- frame_data *fdata;
cf_callback_invoke(cf_cb_file_save_started, (gpointer)fname);
+ addrs = get_addrinfo_list();
+
if (save_format == cf->cd_t && compressed == cf->iscompressed
- && !discard_comments && !cf->unsaved_changes) {
+ && !discard_comments && !cf->unsaved_changes
+ && !(addrs && addrs->ai_next &&
+ wtap_dump_has_name_resolution(save_format))) {
/* We're saving in the format it's already in, and we're
not discarding comments, and there are no changes we have
- in memory that aren't saved to the file, so we can just move
- or copy the raw data. */
+ in memory that aren't saved to the file, and we have no name
+ resolution blocks to write, so we can just move or copy the raw data. */
if (cf->is_tempfile) {
/* The file being saved is a temporary file from a live
@@ -4440,7 +4470,7 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format,
}
/* Add address resolution */
- wtap_dump_set_addrinfo_list(pdh, get_addrinfo_list());
+ wtap_dump_set_addrinfo_list(pdh, addrs);
/* Iterate through the list of packets, processing all the packets. */
callback_args.pdh = pdh;