aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2022-05-13 09:19:16 -0400
committerA Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2022-05-13 13:41:28 +0000
commit1f1ee198f2d013f1580958ded143b6e150093324 (patch)
tree262f6ea17f17704de282b1dbfb2451e47c3c18d6 /wiretap
parentbebf7afa37bc49d8f58ec68c71459a005d5c3652 (diff)
merge: Don't write to stdout if tempdir is not set
If merge_files_common() is called with a non NULL value for out_filenamep, that always indicates tempfile mode, even if the tempdir is not set. A NULL value for the tempdir is handled by wtap_dump_open_tempfile, which writes to the OS default temp directory. Only write to stdout if both out_filename and out_filenamep are NULL. Fixes a crash introduced by commit 1e0d117eb7ab1ce7f4ff8a4f when selecting Merge from the GUI and the new temp_dir option is not set.
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/merge.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/wiretap/merge.c b/wiretap/merge.c
index 05a48ad90a..b838f6d712 100644
--- a/wiretap/merge.c
+++ b/wiretap/merge.c
@@ -985,7 +985,8 @@ merge_process_packets(wtap_dumper *pdh, const int file_type,
}
static merge_result
-merge_files_common(const gchar* out_filename, /* normal output mode */
+merge_files_common(const gchar* out_filename, /* filename in normal output mode,
+ optional tempdir in tempfile mode (NULL for OS default) */
gchar **out_filenamep, const char *pfx, /* tempfile mode */
const int file_type, const char *const *in_filenames,
const guint in_file_count, const gboolean do_append,
@@ -1065,13 +1066,13 @@ merge_files_common(const gchar* out_filename, /* normal output mode */
dsb_combined = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
params.dsbs_growing = dsb_combined;
}
- if (out_filename && !out_filenamep) {
- pdh = wtap_dump_open(out_filename, file_type, WTAP_UNCOMPRESSED,
- &params, err, err_info);
- } else if (out_filename && out_filenamep) {
+ if (out_filenamep) {
pdh = wtap_dump_open_tempfile(out_filename, out_filenamep, pfx, file_type,
WTAP_UNCOMPRESSED, &params, err,
err_info);
+ } else if (out_filename) {
+ pdh = wtap_dump_open(out_filename, file_type, WTAP_UNCOMPRESSED,
+ &params, err, err_info);
} else {
pdh = wtap_dump_open_stdout(file_type, WTAP_UNCOMPRESSED, &params, err,
err_info);