From: Guy Harris Date: Fri, 15 Aug 2014 00:21:09 +0000 (-0700) Subject: Merge git://github.com/the-tcpdump-group/tcpdump X-Git-Tag: tcpdump-4.7.0-bp~46^2~8 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/2456fb746ccd1f6d309f673f67940dd0de02400f Merge git://github.com/the-tcpdump-group/tcpdump --- 2456fb746ccd1f6d309f673f67940dd0de02400f diff --cc print-cdp.c index 42ea1b7f,c5fc8b11..74d9a52e --- a/print-cdp.c +++ b/print-cdp.c @@@ -103,24 -104,11 +104,24 @@@ cdp_print(netdissect_options *ndo tptr += CDP_HEADER_LEN; while (tptr < (pptr+length)) { - ND_TCHECK2(*tptr, 4); /* read out Type and Length */ + ND_TCHECK2(*tptr, CDP_HEADER_LEN); /* read out Type and Length */ type = EXTRACT_16BITS(tptr); - len = EXTRACT_16BITS(tptr+2); /* object length includes the 4 bytes header length */ - if (len < 4) { + len = EXTRACT_16BITS(tptr+CDP_HEADER_OFFSET); /* object length includes the 4 bytes header length */ ++ if (len < CDP_HEADER_LEN) { + if (ndo->ndo_vflag) + ND_PRINT((ndo, "\n\t%s (0x%02x), length: %u byte%s (too short)", + tok2str(cdp_tlv_values,"unknown field type", type), + type, + len, + PLURAL_SUFFIX(len))); /* plural */ + else + ND_PRINT((ndo, ", %s TLV length %u too short", + tok2str(cdp_tlv_values,"unknown field type", type), + len)); + break; + } - tptr += 4; - len -= 4; + tptr += CDP_HEADER_LEN; + len -= CDP_HEADER_LEN; ND_TCHECK2(*tptr, len);