X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/df8ee0903548456db62ea60cbd5f7fbca8e92de3..c4a92483fc1f1865a7cd8974edf6ca63c57abef7:/print-ldp.c diff --git a/print-ldp.c b/print-ldp.c index 5fc1f72b..a3e7a2dc 100644 --- a/print-ldp.c +++ b/print-ldp.c @@ -16,7 +16,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.12 2005-04-27 19:16:21 guy Exp $"; + "@(#) $Header: /tcpdump/master/tcpdump/print-ldp.c,v 1.14 2005-06-16 01:10:21 guy Exp $"; #endif #ifdef HAVE_CONFIG_H @@ -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