From b009bf6d378704eec392b31f9b6f473daaacb206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Thu, 4 Jul 2019 01:33:20 +0300 Subject: [PATCH] Only read at max 1522 bytes of the 1522 byte buffer --- ethertype-dump.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ethertype-dump.c b/ethertype-dump.c index 402e5a9..3c3280e 100644 --- a/ethertype-dump.c +++ b/ethertype-dump.c @@ -104,6 +104,7 @@ int main(int argc, char **argv) { if (frame_length == -1) { err(1, "recv"); } + size_t frame_data_length = frame_length <= 1522 ? frame_length : 1522; if (frame_length < 64) { errno = 0; @@ -114,7 +115,7 @@ int main(int argc, char **argv) { } // Compute the CRC32 of the frame - uint32_t crc32_residue = crc32(frame, frame_length); + uint32_t crc32_residue = crc32(frame, frame_data_length); if (crc32_residue != 0xc704dd7b) { errno = 0;