]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ppp.c
Do the dump file Capsicum stuff in a common routine.
[tcpdump] / print-ppp.c
index b92abf2751e44a879eed3a9ac1c0e965c8d8306c..edc03c021c4e27a43eccad12b6475f6f7e62c9b8 100644 (file)
@@ -738,9 +738,8 @@ print_lcp_config_options(netdissect_options *ndo,
                                ND_PRINT((ndo, " (length bogus, should be = 9)"));
                                return 0;
                        }
-                       ND_TCHECK(p[8]);
-                       ND_PRINT((ndo, ": MAC %02x:%02x:%02x:%02x:%02x:%02x",
-                              p[3], p[4], p[5], p[6], p[7], p[8]));
+                       ND_TCHECK2(*(p + 3), 6);
+                       ND_PRINT((ndo, ": MAC %s", etheraddr_string(ndo, p + 3)));
                        break;
                case MEDCLASS_MNB:
                        ND_PRINT((ndo, ": Magic-Num-Block")); /* XXX */
@@ -806,8 +805,8 @@ static const struct tok ppp_ml_flag_values[] = {
 
 static void
 handle_mlppp(netdissect_options *ndo,
-             const u_char *p, int length) {
-
+             const u_char *p, int length)
+{
     if (!ndo->ndo_eflag)
         ND_PRINT((ndo, "MLPPP, "));
 
@@ -1352,14 +1351,15 @@ static void
 ppp_hdlc(netdissect_options *ndo,
          const u_char *p, int length)
 {
-       u_char *b, *s, *t, c;
+       u_char *b, *t, c;
+       const u_char *s;
        int i, proto;
        const void *se;
 
         if (length <= 0)
                 return;
 
-       b = (uint8_t *)malloc(length);
+       b = (u_char *)malloc(length);
        if (b == NULL)
                return;
 
@@ -1368,14 +1368,13 @@ ppp_hdlc(netdissect_options *ndo,
         * Do this so that we dont overwrite the original packet
         * contents.
         */
-       for (s = (u_char *)p, t = b, i = length; i > 0; i--) {
+       for (s = p, t = b, i = length; i > 0 && ND_TTEST(*s); i--) {
                c = *s++;
                if (c == 0x7d) {
-                       if (i > 1) {
-                               i--;
-                               c = *s++ ^ 0x20;
-                       } else
-                               continue;
+                       if (i <= 1 || !ND_TTEST(*s))
+                               break;
+                       i--;
+                       c = *s++ ^ 0x20;
                }
                *t++ = c;
        }
@@ -1393,11 +1392,9 @@ ppp_hdlc(netdissect_options *ndo,
         case PPP_IP:
                ip_print(ndo, b + 1, length - 1);
                goto cleanup;
-#ifdef INET6
         case PPP_IPV6:
                ip6_print(ndo, b + 1, length - 1);
                goto cleanup;
-#endif
         default: /* no luck - try next guess */
                break;
         }
@@ -1467,12 +1464,10 @@ handle_ppp(netdissect_options *ndo,
        case PPP_IP:
                ip_print(ndo, p, length);
                break;
-#ifdef INET6
        case ETHERTYPE_IPV6:    /*XXX*/
        case PPP_IPV6:
                ip6_print(ndo, p, length);
                break;
-#endif
        case ETHERTYPE_IPX:     /*XXX*/
        case PPP_IPX:
                ipx_print(ndo, p, length);
@@ -1782,11 +1777,9 @@ ppp_bsdos_if_print(netdissect_options *ndo _U_,
                        case PPP_IP:
                                ip_print(ndo, p, length);
                                break;
-#ifdef INET6
                        case PPP_IPV6:
                                ip6_print(ndo, p, length);
                                break;
-#endif
                        case PPP_MPLS_UCAST:
                        case PPP_MPLS_MCAST:
                                mpls_print(ndo, p, length);
@@ -1801,11 +1794,9 @@ ppp_bsdos_if_print(netdissect_options *ndo _U_,
                        case PPP_IP:
                                ip_print(ndo, p, length);
                                break;
-#ifdef INET6
                        case PPP_IPV6:
                                ip6_print(ndo, p, length);
                                break;
-#endif
                        case PPP_MPLS_UCAST:
                        case PPP_MPLS_MCAST:
                                mpls_print(ndo, p, length);
@@ -1833,11 +1824,9 @@ ppp_bsdos_if_print(netdissect_options *ndo _U_,
        case PPP_IP:
                ip_print(p, length);
                break;
-#ifdef INET6
        case PPP_IPV6:
                ip6_print(ndo, p, length);
                break;
-#endif
        case PPP_MPLS_UCAST:
        case PPP_MPLS_MCAST:
                mpls_print(ndo, p, length);