]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-lldp.c
Handle very large -f files by rejecting them.
[tcpdump] / print-lldp.c
index b7934861df1cbb0b7b3cd5b5f700ec85046d0a05..e87b16bd0fcc16444599148d7e4f029298a0be30 100644 (file)
@@ -12,7 +12,7 @@
  * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  * FOR A PARTICULAR PURPOSE.
  *
- * Original code by Hannes Gredler (hannes@juniper.net)
+ * Original code by Hannes Gredler (hannes@gredler.at)
  * IEEE and TIA extensions by Carles Kishimoto <[email protected]>
  * DCBX extensions by Kaladhar Musunuru <[email protected]>
  */
@@ -590,6 +590,7 @@ static const struct tok lldp_evb_mode_values[]={
     { LLDP_EVB_MODE_EVB_BRIDGE, "EVB Bridge"},
     { LLDP_EVB_MODE_EVB_STATION, "EVB Staion"},
     { LLDP_EVB_MODE_RESERVED, "Reserved for future Standardization"},
+    { 0, NULL},
 };
 
 #define NO_OF_BITS 8
@@ -604,8 +605,8 @@ static const struct tok lldp_evb_mode_values[]={
 #define LLDP_IANA_SUBTYPE_MUDURL 1
 
 static const struct tok lldp_iana_subtype_values[] =   {
-  { LLDP_IANA_SUBTYPE_MUDURL, "MUD-URL" },
-  { 0, NULL }
+    { LLDP_IANA_SUBTYPE_MUDURL, "MUD-URL" },
+    { 0, NULL }
 };
 
 
@@ -650,7 +651,7 @@ lldp_private_8021_print(netdissect_options *ndo,
     int subtype, hexdump = FALSE;
     u_int sublen;
     u_int tval;
-    uint8_t i;
+    u_int i;
 
     if (tlv_len < 4) {
         return hexdump;
@@ -786,9 +787,9 @@ lldp_private_8021_print(netdissect_options *ndo,
         ND_PRINT((ndo, "\n\t    Application Priority Table"));
         while(i<sublen) {
                tval=*(tptr+i+5);
-               ND_PRINT((ndo, "\n\t      Priority: %d, RES: %d, Sel: %d",
-                        tval >> 5, (tval >> 3) & 0x03, (tval & 0x07)));
-               ND_PRINT((ndo, "Protocol ID: %d", EXTRACT_16BITS(tptr + i + 5)));
+               ND_PRINT((ndo, "\n\t      Priority: %u, RES: %u, Sel: %u, Protocol ID: %u",
+                        tval >> 5, (tval >> 3) & 0x03, (tval & 0x07),
+                        EXTRACT_16BITS(tptr + i + 5)));
                i=i+3;
         }
         break;
@@ -897,6 +898,9 @@ lldp_private_8023_print(netdissect_options *ndo,
         break;
 
     case LLDP_PRIVATE_8023_SUBTYPE_MTU:
+        if (tlv_len < 6) {
+            return hexdump;
+        }
         ND_PRINT((ndo, "\n\t    MTU size %u", EXTRACT_16BITS(tptr + 4)));
         break;
 
@@ -926,7 +930,7 @@ lldp_extract_latlon(const u_char *tptr)
  * (right now there is only one)
  */
 
+
 static int
 lldp_private_iana_print(netdissect_options *ndo,
                         const u_char *tptr, u_int tlv_len)
@@ -944,17 +948,18 @@ lldp_private_iana_print(netdissect_options *ndo,
 
     switch (subtype) {
     case LLDP_IANA_SUBTYPE_MUDURL:
-      ND_PRINT((ndo,"\n\t  MUD-URL=%.*s",tlv_len-4,tptr+4));
-      break;
+        ND_PRINT((ndo, "\n\t  MUD-URL="));
+        (void)fn_printn(ndo, tptr+4, tlv_len-4, NULL);
+        break;
     default:
-      hexdump=TRUE;
+        hexdump=TRUE;
     }
-    
+
     return hexdump;
 }
 
 
-      
+
 /*
  * Print private TIA extensions.
  */
@@ -1399,7 +1404,7 @@ lldp_mgmt_addr_tlv_print(netdissect_options *ndo,
     if (tlen) {
         oid_len = *tptr;
 
-        if (tlen < oid_len) {
+        if (tlen < 1U + oid_len) {
             return 0;
         }
         if (oid_len) {
@@ -1615,8 +1620,8 @@ lldp_print(netdissect_options *ndo,
                     hexdump = lldp_private_8023_print(ndo, tptr, tlv_len);
                     break;
                case OUI_IANA:
-                 hexdump = lldp_private_iana_print(ndo,tptr,tlv_len);
-                   break;
+                    hexdump = lldp_private_iana_print(ndo, tptr, tlv_len);
+                    break;
                 case OUI_TIA:
                     hexdump = lldp_private_tia_print(ndo, tptr, tlv_len);
                     break;