]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-cdp.c
RADIUS: Rename a test with an invalid length
[tcpdump] / print-cdp.c
index 62eeed452d078b851720244a9a831b35ac58bfe7..c66c0d11d962f43efe92f2400d72a66911713076 100644 (file)
@@ -213,7 +213,7 @@ struct cdp_tlvinfo {
 static const struct cdp_tlvinfo cdptlvs[] = {
        /* 0x00 */
        [ 0x01 ] = { "Device-ID", cdp_print_string, VERBOSE_OR_NOT_VERBOSE, -1, -1 },
-       [ 0x02 ] = { "Address", cdp_print_addr, VERBOSE_ONLY, -1, -1 },
+       [ 0x02 ] = { "Address", cdp_print_addr, VERBOSE_ONLY, 4, -1 },
        [ 0x03 ] = { "Port-ID", cdp_print_string, VERBOSE_ONLY, -1, -1 },
        [ 0x04 ] = { "Capability", cdp_print_capability, VERBOSE_ONLY, 4, 4 },
        [ 0x05 ] = { "Version String", cdp_print_version, VERBOSE_ONLY, -1, -1 },
@@ -375,10 +375,6 @@ cdp_print_addr(netdissect_options *ndo,
                0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd
        };
 
-       if (l < 4) {
-               ND_PRINT(" (not enough space for num)");
-               goto invalid;
-       }
        num = GET_BE_U_4(p);
        p += 4;
        l -= 4;
@@ -419,8 +415,7 @@ cdp_print_addr(netdissect_options *ndo,
                        ND_PRINT("IPv4 (%u) %s", num, GET_IPADDR_STRING(p));
                        p += al;
                        l -= al;
-               }
-               else if (pt == PT_IEEE_802_2 && pl == 8 &&
+               } else if (pt == PT_IEEE_802_2 && pl == 8 &&
                         memcmp(p, prot_ipv6, 8) == 0 && al == 16) {
                        /*
                         * IPv6: protocol type = IEEE 802.2 header,
@@ -438,8 +433,7 @@ cdp_print_addr(netdissect_options *ndo,
                        ND_PRINT("IPv6 (%u) %s", num, GET_IP6ADDR_STRING(p));
                        p += al;
                        l -= al;
-               }
-               else {
+               } else {
                        /*
                         * Generic case: just print raw data
                         */