]> The Tcpdump Group git mirrors - tcpdump/commitdiff
pass correct caplen to other functions as well
authorDenis Ovsienko <[email protected]>
Wed, 11 Jan 2017 12:54:45 +0000 (12:54 +0000)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 18 Jan 2017 08:16:41 +0000 (09:16 +0100)
In ethertype_print(), isoclns_print() and snap_print() adjust the length
arithmetics along the same lines as for ether_print() in the previous
commit. Where done, the current pointer is not greater than snapend so
that the difference (i.e. caplen) is never negative.

This does not fix a reported issue but the problem was very likely to be
there.

print-chdlc.c
print-fr.c
print-geneve.c
print-gre.c

index b5ed67db14c1370341c0ca54135e2cb698cd9d25..450d286848cb8590e2b5ebe8e93e586f0a5c6db5 100644 (file)
@@ -97,9 +97,9 @@ chdlc_print(netdissect_options *ndo, register const u_char *p, u_int length)
                 if (*(p+1) == 0x81 ||
                     *(p+1) == 0x82 ||
                     *(p+1) == 0x83)
-                    isoclns_print(ndo, p + 1, length - 1, length - 1);
+                    isoclns_print(ndo, p + 1, length - 1, ndo->ndo_snapend - p - 1);
                 else
-                    isoclns_print(ndo, p, length, length);
+                    isoclns_print(ndo, p, length, ndo->ndo_snapend - p);
                 break;
        default:
                 if (!ndo->ndo_eflag)
index 9c97bcb4a6746ef904f2d580066a84b2127faa19..f400ddcd4f59aee585351c5e3ec19b4976e18974 100644 (file)
@@ -276,7 +276,7 @@ fr_print(netdissect_options *ndo,
                         if (ethertype_print(ndo, extracted_ethertype,
                                             p+addr_len+ETHERTYPE_LEN,
                                             length-addr_len-ETHERTYPE_LEN,
-                                            length-addr_len-ETHERTYPE_LEN,
+                                            ndo->ndo_snapend-p-addr_len-ETHERTYPE_LEN,
                                             NULL, NULL) == 0)
                                 /* ether_type not known, probably it wasn't one */
                                 ND_PRINT((ndo, "UI %02x! ", p[addr_len]));
@@ -329,11 +329,11 @@ fr_print(netdissect_options *ndo,
        case NLPID_CLNP:
        case NLPID_ESIS:
        case NLPID_ISIS:
-               isoclns_print(ndo, p - 1, length + 1, length + 1); /* OSI printers need the NLPID field */
+               isoclns_print(ndo, p - 1, length + 1, ndo->ndo_snapend - p + 1); /* OSI printers need the NLPID field */
                break;
 
        case NLPID_SNAP:
-               if (snap_print(ndo, p, length, length, NULL, NULL, 0) == 0) {
+               if (snap_print(ndo, p, length, ndo->ndo_snapend - p, NULL, NULL, 0) == 0) {
                        /* ether_type not known, print raw packet */
                         if (!ndo->ndo_eflag)
                             fr_hdr_print(ndo, length + hdr_len, hdr_len,
index d1ed242fda6ab533c9af6ace3eb8f2c8cdee08d7..40402ab4200cd7ebcb0eac3eed4dc91d656c1fb1 100644 (file)
@@ -223,7 +223,7 @@ geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
     else
         ND_PRINT((ndo, "\n\t"));
 
-    if (ethertype_print(ndo, prot, bp, len, len, NULL, NULL) == 0) {
+    if (ethertype_print(ndo, prot, bp, len, ndo->ndo_snapend - bp, NULL, NULL) == 0) {
         if (prot == ETHERTYPE_TEB)
             ether_print(ndo, bp, len, ndo->ndo_snapend - bp, NULL, NULL);
         else
index e0f60c944dd0ef13f83f0dea76d8a20c5b41f212..505752a1b8fad1b0ccd213b1e1ed7f6764707274 100644 (file)
@@ -226,7 +226,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
                atalk_print(ndo, bp, len);
                break;
        case ETHERTYPE_GRE_ISO:
-               isoclns_print(ndo, bp, len, len);
+               isoclns_print(ndo, bp, len, ndo->ndo_snapend - bp);
                break;
        case ETHERTYPE_TEB:
                ether_print(ndo, bp, len, ndo->ndo_snapend - bp, NULL, NULL);