From: Marek Lindner Date: Wed, 29 Apr 2020 12:09:44 +0200 Subject: batctl: fix endianness when reading radiotap header All radiotap header fields are specified in little endian byte-order. Header length conversion is necessary on some platforms. Fixes: c6fcdb6dc9a9 ("batctl: add radiotap wifi packet decapsulation support") Signed-off-by: Marek Lindner Signed-off-by: Sven Eckelmann Origin: upstream, https://git.open-mesh.org/batctl.git/commit/440ae55a6ef96eb73ee628f9237915cf9fb26dee diff --git a/tcpdump.c b/tcpdump.c index dc4ccd37c3ddf8650cb79737defd923fe9f33c64..c41500e21eda0abc1f024a3265c23fc3a4802d17 100644 --- a/tcpdump.c +++ b/tcpdump.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -1048,10 +1049,10 @@ static int monitor_header_length(unsigned char *packet_buff, ssize_t buff_len, i return -1; radiotap_hdr = (struct radiotap_header*)packet_buff; - if (buff_len <= radiotap_hdr->it_len) + if (buff_len <= le16toh(radiotap_hdr->it_len)) return -1; else - return radiotap_hdr->it_len; + return le16toh(radiotap_hdr->it_len); } return -1;