From 42617ae88a39071f001d2f84fd92f55ddf1ddbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Thu, 4 Jul 2019 12:34:13 +0300 Subject: [PATCH] Don't handle overlong frames like runt frames --- ethertype-dump.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ethertype-dump.c b/ethertype-dump.c index 81aa195..27c4fa2 100644 --- a/ethertype-dump.c +++ b/ethertype-dump.c @@ -82,14 +82,6 @@ int main(int argc, char **argv) { continue; } - if (frame_length > 1522) { - errno = 0; - if (printf("Overlong frame (%zdB)\n", frame_length) == -1) { - err(1, "printf"); - } - continue; - } - // Extract the MACs // 012345 012345 // dest source @@ -123,11 +115,22 @@ int main(int argc, char **argv) { errno = 0; if (ethertype_meaning == NULL) { - if (printf(", length: %zd\n", frame_length) == -1) { + if (printf(", length: %zd", frame_length) == -1) { err(1, "printf"); } } else { - if (printf(" (%s), length: %zd\n", ethertype_meaning, frame_length) == -1) { + if (printf(" (%s), length: %zd", ethertype_meaning, frame_length) == -1) { + err(1, "printf"); + } + } + + errno = 0; + if (frame_length > 1522) { + if (printf(" (overlong)\n") == -1) { + err(1, "printf"); + } + } else { + if (printf("\n") == -1) { err(1, "printf"); } }