summaryrefslogtreecommitdiffstats
path: root/wiretap/merge.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--wiretap/merge.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/wiretap/merge.c b/wiretap/merge.c
index 82154f9b..3c007dd6 100644
--- a/wiretap/merge.c
+++ b/wiretap/merge.c
@@ -1420,6 +1420,22 @@ merge_files(const gchar* out_filename, const int file_type,
guint32 *err_framenum)
{
ws_assert(out_filename != NULL);
+ ws_assert(in_file_count > 0);
+ ws_assert(in_filenames != NULL);
+ ws_assert(err_info != NULL);
+
+ /* #19402: ensure we aren't appending to one of our inputs */
+ if (do_append) {
+ unsigned int i;
+ for (i = 0; i < in_file_count; i++) {
+ if (files_identical(out_filename, in_filenames[i])) {
+ *err_info = ws_strdup_printf("Output file %s is same as input file %s; "
+ "appending would create infinite loop",
+ out_filename, in_filenames[i]);
+ return MERGE_ERR_INVALID_OPTION;
+ }
+ }
+ }
return merge_files_common(out_filename, NULL, NULL,
file_type, in_filenames, in_file_count,