aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2023-10-15 08:48:43 -0400
committerJohn Thacker <johnthacker@gmail.com>2023-10-15 09:07:45 -0400
commit64937eb5521b67921e70866357bc3803e082a776 (patch)
treee371ca86938e5e26e4d4719b480820246f186c79 /wiretap
parenta4b6cd460d1c716c12d0277be27cc47d5b9b1fe1 (diff)
merge: Add merge comment
The merge code tries to add a comment about what file names are part of the merge. However, it's been doing so by appending that comment information to the first comment in the first SHB of the first source file, and doing nothing if there isn't an existing comment. Ensure that the comment is always there by adding the comment instead. Perhaps it should be prepended instead. Fix #13839
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/merge.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/wiretap/merge.c b/wiretap/merge.c
index 82154f9bfd..a5dfc0b050 100644
--- a/wiretap/merge.c
+++ b/wiretap/merge.c
@@ -490,7 +490,6 @@ create_shb_header(const merge_in_file_t *in_files, const guint in_file_count,
GString *comment_gstr;
GString *os_info_str;
guint i;
- char* shb_comment = NULL;
wtapng_section_mandatory_t* shb_data;
gsize opt_len;
gchar *opt_str;
@@ -505,14 +504,7 @@ create_shb_header(const merge_in_file_t *in_files, const guint in_file_count,
*
* XXX - do we want some way to record which comments, hardware/OS/app
* descriptions, IDBs, etc.? came from which files?
- *
- * XXX - fix this to handle multiple comments from a single file.
*/
- if (wtap_block_get_nth_string_option_value(shb_hdr, OPT_COMMENT, 0, &shb_comment) == WTAP_OPTTYPE_SUCCESS &&
- strlen(shb_comment) > 0) {
- /* very lame way to save comments - does not save them from the other files */
- g_string_append_printf(comment_gstr, "%s \n",shb_comment);
- }
g_string_append_printf(comment_gstr, "File created by merging: \n");
@@ -527,9 +519,14 @@ create_shb_header(const merge_in_file_t *in_files, const guint in_file_count,
shb_data->section_length = -1;
/* TODO: handle comments from each file being merged */
opt_len = comment_gstr->len;
+ /* XXX: 65535 is the maximum size for an option (hence comment) in pcapng.
+ * Truncate it? Let wiretap/pcapng.c decide what to do? (Currently it
+ * writes nothing without reporting an error.) What if we support other
+ * output file formats later?
+ */
opt_str = g_string_free(comment_gstr, FALSE);
- wtap_block_set_nth_string_option_value(shb_hdr, OPT_COMMENT, 0, opt_str, opt_len); /* section comment */
- g_free(opt_str);
+ /* XXX: We probably want to prepend (insert at index 0) instead? */
+ wtap_block_add_string_option_owned(shb_hdr, OPT_COMMENT, opt_str);
/*
* XXX - and how do we preserve all the OPT_SHB_HARDWARE, OPT_SHB_OS,
* and OPT_SHB_USERAPPL values from all the previous files?