]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Have various routines for printing non-final headers for IPv4/IPv6
authorguy <guy>
Wed, 19 Nov 2003 00:35:43 +0000 (00:35 +0000)
committerguy <guy>
Wed, 19 Nov 2003 00:35:43 +0000 (00:35 +0000)
return -1 if they run out of data.

Have the IPv4 and IPv6 dissectors check for non-positive return values
from those routines and quit if they see one.

print-ah.c
print-esp.c
print-frag6.c
print-ip.c
print-ip6.c
print-ip6opts.c
print-ipcomp.c
print-rt6.c

index 6d67cd5912f1216ce5ef55c4c7ae11836f8b7627..379f8b3c1e3920e76ddbadc21d6763b4542076c1 100644 (file)
@@ -23,7 +23,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.19.2.2 2003-11-16 08:51:08 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ah.c,v 1.19.2.3 2003-11-19 00:35:43 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -67,5 +67,5 @@ ah_print(register const u_char *bp)
        return sizeof(struct ah) + sumlen;
  trunc:
        fputs("[|AH]", stdout);
-       return 65535;
+       return -1;
 }
index 4e1547cd05c2781ed42c3ef7d27907bc25689c70..8acb286a6b3f29ac808bc913af71577549ed54bc 100644 (file)
@@ -23,7 +23,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.44.2.2 2003-11-16 08:51:19 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.44.2.3 2003-11-19 00:35:43 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -337,7 +337,12 @@ esp_print(const u_char *bp, const u_char *bp2
        _U_
 #endif
        ,
-       int *nhdr, int *padlen
+       int *nhdr
+#ifndef HAVE_LIBCRYPTO
+       _U_
+#endif
+       ,
+       int *padlen
 #ifndef HAVE_LIBCRYPTO
        _U_
 #endif
@@ -367,7 +372,7 @@ esp_print(const u_char *bp, const u_char *bp2
 
 #ifdef HAVE_LIBCRYPTO
        secret = NULL;
-       advance = 0;
+       padvance = 0;
 
        if (!initialized) {
                esp_init();
@@ -501,7 +506,5 @@ esp_print(const u_char *bp, const u_char *bp2
 #endif
 
 fail:
-       if (nhdr)
-               *nhdr = -1;
-       return 65536;
+       return -1;
 }
index c7c774d96eb5cf1cf823c1af834059a6579625d2..3f4326554cf38eedc7b0ceb195a63c3954697386 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.16.2.2 2003-11-16 08:51:23 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-frag6.c,v 1.16.2.3 2003-11-19 00:35:43 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -71,7 +71,7 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
 #if 1
        /* it is meaningless to decode non-first fragment */
        if ((EXTRACT_16BITS(&dp->ip6f_offlg) & IP6F_OFF_MASK) != 0)
-               return 65535;
+               return -1;
        else
 #endif
        {
@@ -80,7 +80,7 @@ frag6_print(register const u_char *bp, register const u_char *bp2)
        }
 trunc:
        fputs("[|frag]", stdout);
-       return 65535;
+       return -1;
 #undef TCHECK
 }
 #endif /* INET6 */
index dd427caf07229857cdea0cf96f42c9b0ab319e4b..8d9e874f34d73677f360903d05188cce107619e7 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.128.2.3 2003-11-19 00:17:01 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.128.2.4 2003-11-19 00:35:44 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -478,6 +478,8 @@ again:
                case IPPROTO_AH:
                        nh = *cp;
                        advance = ah_print(cp);
+                       if (advance <= 0)
+                               break;
                        cp += advance;
                        len -= advance;
                        goto again;
@@ -486,10 +488,10 @@ again:
                    {
                        int enh, padlen;
                        advance = esp_print(cp, (const u_char *)ip, &enh, &padlen);
+                       if (advance <= 0)
+                               break;
                        cp += advance;
                        len -= advance + padlen;
-                       if (enh < 0)
-                               break;
                        nh = enh & 0xff;
                        goto again;
                    }
@@ -498,10 +500,10 @@ again:
                    {
                        int enh;
                        advance = ipcomp_print(cp, &enh);
+                       if (advance <= 0)
+                               break;
                        cp += advance;
                        len -= advance;
-                       if (enh < 0)
-                               break;
                        nh = enh & 0xff;
                        goto again;
                    }
index d9179160934db14423385c2581de314e760e337c..1916c17fa9cdad4f74ba5a0088d47a009447bd8e 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.32.2.3 2003-11-19 00:17:02 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ip6.c,v 1.32.2.4 2003-11-19 00:35:44 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -81,7 +81,7 @@ ip6_print(register const u_char *bp, register u_int length)
        cp = (const u_char *)ip6;
        advance = sizeof(struct ip6_hdr);
        nh = ip6->ip6_nxt;
-       while (cp < snapend) {
+       while (cp < snapend && advance > 0) {
                cp += advance;
                len -= advance;
 
@@ -144,8 +144,6 @@ ip6_print(register const u_char *bp, register u_int length)
                    {
                        int enh, padlen;
                        advance = esp_print(cp, (const u_char *)ip6, &enh, &padlen);
-                       if (enh < 0)
-                               goto end;
                        nh = enh & 0xff;
                        len -= padlen;
                        break;
@@ -154,8 +152,6 @@ ip6_print(register const u_char *bp, register u_int length)
                    {
                        int enh;
                        advance = ipcomp_print(cp, &enh);
-                       if (enh < 0)
-                               goto end;
                        nh = enh & 0xff;
                        break;
                    }
index bf43fe0c79aab576bf3fab856e052f4a53b4063f..9047e8dc20f41c4c2aea296b08c4b69cc1b852f0 100644 (file)
@@ -33,7 +33,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.14.2.2 2003-11-16 08:51:27 guy Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/print-ip6opts.c,v 1.14.2.3 2003-11-19 00:35:44 guy Exp $";
 #endif
 
 #ifdef INET6
@@ -305,7 +305,7 @@ hbhopt_print(register const u_char *bp)
 
   trunc:
     fputs("[|HBH]", stdout);
-    return(hbhlen);
+    return(-1);
 }
 
 int
@@ -330,6 +330,6 @@ dstopt_print(register const u_char *bp)
 
   trunc:
     fputs("[|DSTOPT]", stdout);
-    return(dstoptlen);
+    return(-1);
 }
 #endif /* INET6 */
index b1f611b3c68f6c087d0f469f1fd662b305550a39..1f1c23a6440f0b681169e53ae3d461b4f7243ddc 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.17.2.2 2003-11-16 08:51:27 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ipcomp.c,v 1.17.2.3 2003-11-19 00:35:45 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -48,7 +48,7 @@ struct ipcomp {
 #include "extract.h"
 
 int
-ipcomp_print(register const u_char *bp, int *nhdr)
+ipcomp_print(register const u_char *bp, int *nhdr _U_)
 {
        register const struct ipcomp *ipcomp;
        register const u_char *ep;
@@ -87,7 +87,5 @@ ipcomp_print(register const u_char *bp, int *nhdr)
 
 #endif
 fail:
-       if (nhdr)
-               *nhdr = -1;
-       return 65536;
+       return -1;
 }
index 19026d4d7156438e82b50e01e6dabccb12aa8df2..ce14f74cc93d0646ce70dfb85469aab20266df31 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.23.2.2 2003-11-16 08:51:43 guy Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-rt6.c,v 1.23.2.3 2003-11-19 00:35:45 guy Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -102,6 +102,6 @@ rt6_print(register const u_char *bp, register const u_char *bp2)
 
  trunc:
        fputs("[|srcrt]", stdout);
-       return 65535;           /* XXX */
+       return -1;
 }
 #endif /* INET6 */