summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2017-06-01 16:00:50 +0200
committerWim Taymans <wtaymans@redhat.com>2017-06-01 16:38:39 +0200
commit360eb81d67cdd95a5b39a6c5ffbbbd80df7b072b (patch)
tree95bda94a8a1b67a56a27ffede2848c4844ca5c8b
parentff54f6d93053042b062a448f34128d97f99a45d0 (diff)
downloadgstreamer-plugins-bad-360eb81d67cdd95a5b39a6c5ffbbbd80df7b072b.tar.gz
pcapparse: endianness fix
Also swap the linktype after we detected that we need to do byteswapping. Fixes a problem with reading pcap files generated on a machine with different endianness.
-rw-r--r--gst/pcapparse/gstpcapparse.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/gst/pcapparse/gstpcapparse.c b/gst/pcapparse/gstpcapparse.c
index 6bd293a75..67ae4a1fb 100644
--- a/gst/pcapparse/gstpcapparse.c
+++ b/gst/pcapparse/gstpcapparse.c
@@ -550,14 +550,15 @@ gst_pcap_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
magic = *((guint32 *) data);
major_version = *((guint16 *) (data + 4));
- linktype = gst_pcap_parse_read_uint32 (self, data + 20);
+ linktype = *((guint32 *) (data + 20));
gst_adapter_unmap (self->adapter);
if (magic == 0xa1b2c3d4) {
self->swap_endian = FALSE;
} else if (magic == 0xd4c3b2a1) {
self->swap_endian = TRUE;
- major_version = major_version << 8 | major_version >> 8;
+ major_version = GUINT16_SWAP_LE_BE (major_version);
+ linktype = GUINT32_SWAP_LE_BE (linktype);
} else {
GST_ELEMENT_ERROR (self, STREAM, WRONG_TYPE, (NULL),
("File is not a libpcap file, magic is %X", magic));