]> The Tcpdump Group git mirrors - tcpdump/commitdiff
No more need for ndo_invalid_header in struct netdissect_options
authorFrancois-Xavier Le Bail <[email protected]>
Thu, 25 Jan 2018 13:17:57 +0000 (14:17 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Thu, 25 Jan 2018 14:12:24 +0000 (15:12 +0100)
Because we now stop decoding packet when header length(s) is/are invalid,
there is no more need to keep the invalid header flag out of
pretty_print_packet function.

netdissect.h
print.c

index 8d6c0fb7e94ef299eee25763980d69bf94cf8023..2bbfda30248d611abec4437de06f1bcda852d55b 100644 (file)
@@ -191,7 +191,6 @@ struct netdissect_options {
                                 * LF, CR and SPACE as graphical chars
                                 */
   int ndo_Hflag;               /* dissect 802.11s draft mesh standard */
-  int ndo_invalid_header;
   int ndo_packet_number;       /* print a packet number in the beginning of line */
   int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */
   int ndo_tstamp_precision;    /* requested time stamp precision */
diff --git a/print.c b/print.c
index 7ab74727b6eeaaea7c9d53c4418d35b820285dcf..70a0043c78d876d85b2dbfe03935c40bb3e77736 100644 (file)
--- a/print.c
+++ b/print.c
@@ -313,32 +313,32 @@ pretty_print_packet(netdissect_options *ndo, const struct pcap_pkthdr *h,
     const u_char *sp, u_int packets_captured)
 {
        u_int hdrlen;
+       int invalid_header = 0;
 
        if(ndo->ndo_packet_number)
                ND_PRINT("%5u  ", packets_captured);
 
        /* Sanity checks on packet length / capture length */
-       ndo->ndo_invalid_header = 0;
        if(h->caplen == 0) {
-               ndo->ndo_invalid_header = 1;
+               invalid_header = 1;
                ND_PRINT("[Invalid header: caplen==0");
        }
        if (h->len == 0) {
-               if (!ndo->ndo_invalid_header) {
-                       ndo->ndo_invalid_header = 1;
+               if (!invalid_header) {
+                       invalid_header = 1;
                        ND_PRINT("[Invalid header:");
                } else
                        ND_PRINT(",");
                ND_PRINT(" len==0");
        } else if (h->len < h->caplen) {
-               if (!ndo->ndo_invalid_header) {
-                       ndo->ndo_invalid_header = 1;
+               if (!invalid_header) {
+                       invalid_header = 1;
                        ND_PRINT("[Invalid header:");
                } else
                        ND_PRINT(",");
                ND_PRINT(" len(%u) < caplen(%u)", h->len, h->caplen);
        }
-       if (ndo->ndo_invalid_header) {
+       if (invalid_header) {
                ND_PRINT("]\n");
                return;
        }