aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2022-05-30 15:18:50 -0400
committerA Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2022-06-01 02:03:57 +0000
commit0d2e248a25f5e2bd4af5859521d4fc6b7be743c1 (patch)
tree15959333076c83b11a13cc72d79b749fc8b06394 /wiretap
parent429c7a6ce3f76a01f2366a35cfa7adf187ea72c0 (diff)
file: Only change the file descriptors on a Save with Copy
If we do a save with copy, so that we just copied the binary file, everything in the wtap structure should be the same except for the filename and the file descriptors, so just change that instead of closing wtap and reopening it. The current behavior of calling wtap_open_offline does not work for files that have blocks (SHBs, IDBs, NRBs, DSBs, ISBs, etc.) in the middle of the file instead of at the beginning, but we shouldn't have to waste time rescanning the entire file either. In the case where a specific file format reader was manually selected, this will keep the same file format as selected instead of switching to the auto-detection when opening the copy, just as SAVE_WITH_MOVE already does and presumably what the user wants. Update wtap_fdreopen to change the wtap struct's pathname if wtap_fdreopen is called with a different filename than currently. Fix #17472
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/file_access.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c
index 9724c8ef9e..7b7e3f8b66 100644
--- a/wiretap/file_access.c
+++ b/wiretap/file_access.c
@@ -1237,6 +1237,10 @@ wtap_fdreopen(wtap *wth, const char *filename, int *err)
*err = errno;
return FALSE;
}
+ if (strcmp(filename, wth->pathname) != 0) {
+ g_free(wth->pathname);
+ wth->pathname = g_strdup(filename);
+ }
return TRUE;
}