diff mbox series

batctl: fix endianness when reading radiotap header

Message ID 20200429100944.1163472-1-mareklindner@neomailbox.ch
State Accepted, archived
Delegated to: Simon Wunderlich
Headers show
Series batctl: fix endianness when reading radiotap header | expand

Commit Message

Marek Lindner April 29, 2020, 10:09 a.m. UTC
All radiotap header fields are specified in little endian byte-order.
Header length conversion is necessary on some platforms.

Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
 tcpdump.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/tcpdump.c b/tcpdump.c
index 4b9e4f6..1beace1 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1144,10 +1144,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;