]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ldp.c
updated test case output
[tcpdump] / print-ldp.c
index 03686582f0f82179bd926439a8029bc2297ecca2..c8bec13564be8bd88bce5d2011ef71c7ec1bb86f 100644 (file)
@@ -16,7 +16,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.11 2005-04-27 18:55:51 hannes Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.15 2005-07-11 20:15:32 hannes Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -302,7 +302,7 @@ ldp_tlv_print(register const u_char *tptr) {
            printf("IPv4, addresses:");
            for (i=0; i<(tlv_tlen-2)/4; i++) {
                printf(" %s",ipaddr_string(tptr));
-               tptr+=4;
+               tptr+=sizeof(struct in_addr);
            }
        }
 #ifdef INET6
@@ -310,7 +310,7 @@ ldp_tlv_print(register const u_char *tptr) {
            printf("IPv6, addresses:");
            for (i=0; i<(tlv_tlen-2)/16; i++) {
                printf(" %s",ip6addr_string(tptr));
-               tptr+=16;
+               tptr+=sizeof(struct in6_addr);
            }
        }
 #endif
@@ -352,20 +352,31 @@ ldp_tlv_print(register const u_char *tptr) {
        case LDP_FEC_HOSTADDRESS:
            break;
        case LDP_FEC_MARTINI_VC:
+            if (!TTEST2(*tptr, 11))
+                goto trunc;
             vc_info_len = *(tptr+2);
+
            printf(": %s, %scontrol word, group-ID %u, VC-ID %u, VC-info-length: %u",
                   tok2str(l2vpn_encaps_values, "Unknown", EXTRACT_16BITS(tptr)&0x7fff),
                   EXTRACT_16BITS(tptr)&0x8000 ? "" : "no ",
                    EXTRACT_32BITS(tptr+3),
                   EXTRACT_32BITS(tptr+7),
                    vc_info_len);
+
+            if (vc_info_len == 0) /* infinite loop protection */
+                break;
+
             tptr+=11;
+            if (!TTEST2(*tptr, vc_info_len))
+                goto trunc;
 
             while (vc_info_len > 2) {
                 vc_info_tlv_type = *tptr;
                 vc_info_tlv_len = *(tptr+1);
                 if (vc_info_tlv_len < 2)
                     break;
+                if (vc_info_len < vc_info_tlv_len)
+                    break;
 
                 printf("\n\t\tInterface Parameter: %s (0x%02x), len %u",
                        tok2str(ldp_fec_martini_ifparm_values,"Unknown",vc_info_tlv_type),
@@ -463,6 +474,10 @@ ldp_tlv_print(register const u_char *tptr) {
         break;
     }
     return(tlv_len+4); /* Type & Length fields not included */
+trunc:
+    printf("\n\t\t packet exceeded snapshot");
+    return 0;
 }
 
 void
@@ -540,7 +555,7 @@ ldp_msg_print(register const u_char *pptr) {
                EXTRACT_32BITS(&ldp_msg_header->id),
                LDP_MASK_U_BIT(EXTRACT_16BITS(&ldp_msg_header->type)) ? "continue processing" : "ignore");
 
-        if (msg_len ==0) /* infinite loop protection */
+        if (msg_len == 0) /* infinite loop protection */
             return 0;
 
         msg_tptr=tptr+sizeof(struct ldp_msg_header);