]> The Tcpdump Group git mirrors - tcpdump/commitdiff
IPv6 mobility: Fix printing of 'truncated' string
authorFrancois-Xavier Le Bail <[email protected]>
Thu, 18 Aug 2016 14:34:54 +0000 (16:34 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Sun, 9 Oct 2016 18:38:57 +0000 (20:38 +0200)
Moreover:
Fix spaces before tabs

print-mobility.c
tests/cve2015-0261-ipv6.out

index db688f118e615e902c2978c7b3db8d669c7d3b1c..71cc85b5bb05d5c490cbb726371e3358149cbb80 100644 (file)
@@ -40,6 +40,8 @@
 #include "addrtoname.h"
 #include "extract.h"
 
+static const char tstr[] = "[|MOBILITY]";
+
 /* Mobility header */
 struct ip6_mobility {
        uint8_t ip6m_pproto;    /* following payload protocol (for PG) */
@@ -107,7 +109,7 @@ static const unsigned ip6m_hdrlen[IP6M_MAX + 1] = {
 #define IP6MOPT_AUTH          0x5      /* Binding Authorization Data */
 #define IP6MOPT_AUTH_MINLEN    12
 
-static void
+static int
 mobility_opt_print(netdissect_options *ndo,
                    const u_char *bp, const unsigned len)
 {
@@ -181,10 +183,10 @@ mobility_opt_print(netdissect_options *ndo,
                        break;
                }
        }
-       return;
+       return 0;
 
 trunc:
-       ND_PRINT((ndo, "[trunc] "));
+       return 1;
 }
 
 /*
@@ -238,7 +240,7 @@ mobility_print(netdissect_options *ndo,
        case IP6M_HOME_TEST_INIT:
        case IP6M_CAREOF_TEST_INIT:
                hlen = IP6M_MINLEN;
-               if (ndo->ndo_vflag) {
+               if (ndo->ndo_vflag) {
                        ND_TCHECK2(*mh, hlen + 8);
                        ND_PRINT((ndo, " %s Init Cookie=%08x:%08x",
                               type == IP6M_HOME_TEST_INIT ? "Home" : "Care-of",
@@ -252,7 +254,7 @@ mobility_print(netdissect_options *ndo,
                ND_TCHECK(mh->ip6m_data16[0]);
                ND_PRINT((ndo, " nonce id=0x%x", EXTRACT_16BITS(&mh->ip6m_data16[0])));
                hlen = IP6M_MINLEN;
-               if (ndo->ndo_vflag) {
+               if (ndo->ndo_vflag) {
                        ND_TCHECK2(*mh, hlen + 8);
                        ND_PRINT((ndo, " %s Init Cookie=%08x:%08x",
                               type == IP6M_HOME_TEST ? "Home" : "Care-of",
@@ -260,7 +262,7 @@ mobility_print(netdissect_options *ndo,
                               EXTRACT_32BITS(&bp[hlen + 4])));
                }
                hlen += 8;
-               if (ndo->ndo_vflag) {
+               if (ndo->ndo_vflag) {
                        ND_TCHECK2(*mh, hlen + 8);
                        ND_PRINT((ndo, " %s Keygen Token=%08x:%08x",
                               type == IP6M_HOME_TEST ? "Home" : "Care-of",
@@ -322,12 +324,13 @@ mobility_print(netdissect_options *ndo,
                return(mhlen);
                break;
        }
-       if (ndo->ndo_vflag)
-               mobility_opt_print(ndo, &bp[hlen], mhlen - hlen);
+       if (ndo->ndo_vflag)
+               if (mobility_opt_print(ndo, &bp[hlen], mhlen - hlen))
+                       goto trunc;;
 
        return(mhlen);
 
  trunc:
-       ND_PRINT((ndo, "[|MOBILITY]"));
+       ND_PRINT((ndo, "%s", tstr));
        return(mhlen);
 }
index 4674ada71dd1e63273d195a782b4ad5a9ecb6e3e..3658c198306a1f05c99637066c27259e2daa7c2a 100644 (file)
@@ -1,3 +1,3 @@
-IP6 truncated-ip6 - 26325 bytes missing!(class 0x76, flowlabel 0x76767, hlim 103, next-header Mobility (135) payload length: 26470) 6767:6767:6767:6767:6767:6767:6767:6767 > 6767:6767:6767:6767:6767:6767:6767:6705: mobility: BU seq#=26471 HL lifetime=105884(type-0x67: len=103)[trunc] 
+IP6 truncated-ip6 - 26325 bytes missing!(class 0x76, flowlabel 0x76767, hlim 103, next-header Mobility (135) payload length: 26470) 6767:6767:6767:6767:6767:6767:6767:6767 > 6767:6767:6767:6767:6767:6767:6767:6705: mobility: BU seq#=26471 HL lifetime=105884(type-0x67: len=103)[|MOBILITY]
 IP6 truncated-ip6 - 26325 bytes missing!(class 0x76, flowlabel 0x76767, hlim 103, next-header Mobility (135) payload length: 26470) 6767:6767:6767:6767:6767:6767:6767:6767 > 6767:6767:4f67:6767:6767:6767:6767:6767: (header length 8 is too small for type 6)[|MOBILITY]
 EXIT CODE 00000100