aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/visual.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-11-13 19:38:12 -0800
committerGuy Harris <guy@alum.mit.edu>2018-11-14 03:38:45 +0000
commit3aec5e1a2882a04aae33207750e9053d5f73174b (patch)
tree95170a7ef5b35e1046ccf54ec82eba773bc5b021 /wiretap/visual.c
parent25bbbd7c5c031ca166e48141457c2135f465c8b6 (diff)
Catch attempts to write multiple encapsulation types if unsupported.
If, in the process of opening the input file, we determine that it has packets of more than one link-layer type, we can catch attempts to write that file to a file of a format that doesn't support more than one link-layer type at the time we try to open the output file. If, however, we don't discover that the file has more than one link-layer type until we've already created the output file - for example, if we have a pcapng file with a new IDB, with a different link-layer type from previous IDBs, after packet blocks for the earlier interfces - we can't catch that until we try to write the packet. Currently, that causes the packet's data to be written out as is, so the output file claims it's of the file's link-layer type, causing programs reading the file to misdissect the packet. Report WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED on the write attempt instead, and have a nicer error message for WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED on a write. Change-Id: Ic41f2e4367cfe5667eb30c88cc6d3bfe422462f6 Reviewed-on: https://code.wireshark.org/review/30617 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wiretap/visual.c')
-rw-r--r--wiretap/visual.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/wiretap/visual.c b/wiretap/visual.c
index 724bdd79ea..788e5ce00a 100644
--- a/wiretap/visual.c
+++ b/wiretap/visual.c
@@ -639,6 +639,15 @@ static gboolean visual_dump(wtap_dumper *wdh, const wtap_rec *rec,
return FALSE;
}
+ /*
+ * Make sure this packet doesn't have a link-layer type that
+ * differs from the one for the file.
+ */
+ if (wdh->encap != rec->rec_header.packet_header.pkt_encap) {
+ *err = WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED;
+ return FALSE;
+ }
+
/* Don't write anything we're not willing to read. */
if (rec->rec_header.packet_header.caplen > WTAP_MAX_PACKET_SIZE_STANDARD) {
*err = WTAP_ERR_PACKET_TOO_LARGE;