]> The Tcpdump Group git mirrors - tcpdump/commitdiff
some patches to deal with kday pcap files
authorMichael Richardson <[email protected]>
Mon, 16 Feb 2015 19:49:11 +0000 (14:49 -0500)
committerGuy Harris <[email protected]>
Wed, 11 Mar 2015 06:13:30 +0000 (23:13 -0700)
Author:    Michael Richardson <[email protected]>

print-isoclns.c
print-rpki-rtr.c
tests/kday1.out [new file with mode: 0644]
tests/kday2.out [new file with mode: 0644]
tests/kday3.out [new file with mode: 0644]
tests/kday4.out [new file with mode: 0644]
tests/kday5.out [new file with mode: 0644]
tests/kday6.out [new file with mode: 0644]
tests/kday7.out [new file with mode: 0644]
tests/kday8.out [new file with mode: 0644]

index bd109ab9ad2eaf9d5f24d460282747363705048c..dc1613ee021dca2e037ef00eb148ea46d113621d 100644 (file)
@@ -2309,6 +2309,10 @@ isis_print(netdissect_options *ndo,
             length=pdu_len;
        }
 
+        if(length > ndo->ndo_snaplen) {
+                goto trunc;
+        }
+
        ND_TCHECK(*header_lsp);
        ND_PRINT((ndo, "\n\t  lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t  chksum: 0x%04x",
                isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
@@ -3082,14 +3086,19 @@ osi_print_cksum(netdissect_options *ndo,
         uint16_t calculated_checksum;
 
         /* do not attempt to verify the checksum if it is zero */
-        if (!checksum) {
+        if (!checksum || checksum_offset > length) {
                 ND_PRINT((ndo, "(unverified)"));
         } else {
+                unsigned char *truncated = "trunc";
+                //printf("\nosi_print_cksum: %p %u %u %u\n", pptr, checksum_offset, length, ndo->ndo_snaplen);
+                //ND_TCHECK2(pptr, checksum_offset+length);
                 calculated_checksum = create_osi_cksum(pptr, checksum_offset, length);
                 if (checksum == calculated_checksum) {
                         ND_PRINT((ndo, " (correct)"));
                 } else {
-                        ND_PRINT((ndo, " (incorrect should be 0x%04x)", calculated_checksum));
+                        truncated = "incorrect";
+                        //trunc:
+                        ND_PRINT((ndo, " (%s should be 0x%04x)", truncated, calculated_checksum));
                 }
         }
 }
index 101e41dafbbe39f532f087cb7d840c7e1e05667e..da55dd365f39299a5aa1b3754d5fe4df0a83f438 100644 (file)
@@ -178,6 +178,7 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
     pdu_header = (rpki_rtr_pdu *)tptr;
     pdu_type = pdu_header->pdu_type;
     pdu_len = EXTRACT_32BITS(pdu_header->length);
+    ND_TCHECK2(tptr, pdu_len);
     hexdump = FALSE;
 
     ND_PRINT((ndo, "%sRPKI-RTRv%u, %s PDU (%u), length: %u",
@@ -286,6 +287,7 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
                tptr += 4;
                tlen -= 4;
            }
+            printf("text_length: %u tlen %u\n", text_length, tlen);
            if (text_length && (text_length <= tlen )) {
                memcpy(buf, tptr, min(sizeof(buf)-1, text_length));
                buf[text_length] = '\0';
@@ -306,6 +308,11 @@ rpki_rtr_pdu_print (netdissect_options *ndo, const u_char *tptr, u_int indent)
     if (ndo->ndo_vflag > 1 || (ndo->ndo_vflag && hexdump)) {
        print_unknown_data(ndo,tptr,"\n\t  ", pdu_len);
     }
+    return;
+
+ trunc:
+    ND_PRINT((ndo, "|trunc"));
+    return;
 }
 
 void
diff --git a/tests/kday1.out b/tests/kday1.out
new file mode 100644 (file)
index 0000000..5edcdda
--- /dev/null
@@ -0,0 +1 @@
+EXIT CODE 00000100
diff --git a/tests/kday2.out b/tests/kday2.out
new file mode 100644 (file)
index 0000000..5edcdda
--- /dev/null
@@ -0,0 +1 @@
+EXIT CODE 00000100
diff --git a/tests/kday3.out b/tests/kday3.out
new file mode 100644 (file)
index 0000000..5edcdda
--- /dev/null
@@ -0,0 +1 @@
+EXIT CODE 00000100
diff --git a/tests/kday4.out b/tests/kday4.out
new file mode 100644 (file)
index 0000000..5edcdda
--- /dev/null
@@ -0,0 +1 @@
+EXIT CODE 00000100
diff --git a/tests/kday5.out b/tests/kday5.out
new file mode 100644 (file)
index 0000000..5edcdda
--- /dev/null
@@ -0,0 +1 @@
+EXIT CODE 00000100
diff --git a/tests/kday6.out b/tests/kday6.out
new file mode 100644 (file)
index 0000000..5edcdda
--- /dev/null
@@ -0,0 +1 @@
+EXIT CODE 00000100
diff --git a/tests/kday7.out b/tests/kday7.out
new file mode 100644 (file)
index 0000000..5edcdda
--- /dev/null
@@ -0,0 +1 @@
+EXIT CODE 00000100
diff --git a/tests/kday8.out b/tests/kday8.out
new file mode 100644 (file)
index 0000000..5edcdda
--- /dev/null
@@ -0,0 +1 @@
+EXIT CODE 00000100