]> The Tcpdump Group git mirrors - tcpdump/commitdiff
VTP: Add a test on Mgmt Domain Name length
authorFrancois-Xavier Le Bail <[email protected]>
Mon, 12 Sep 2016 12:50:29 +0000 (14:50 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Mon, 12 Sep 2016 13:04:57 +0000 (15:04 +0200)
print-vtp.c

index a96eeb08d15e09f13b5837178ea266e945fad47b..285beb96ae6937695d954feda93be40dd3dc67a3 100644 (file)
@@ -120,7 +120,7 @@ void
 vtp_print (netdissect_options *ndo,
            const u_char *pptr, u_int length)
 {
-    int type, len, tlv_len, tlv_value;
+    int type, len, tlv_len, tlv_value, mgmtd_len;
     const u_char *tptr;
     const struct vtp_vlan_ *vtp_vlan;
 
@@ -145,7 +145,12 @@ vtp_print (netdissect_options *ndo,
 
     /* verbose mode print all fields */
     ND_PRINT((ndo, "\n\tDomain name: "));
-    fn_printzp(ndo, tptr + 4, *(tptr + 3), NULL);
+    mgmtd_len = *(tptr + 3);
+    if (mgmtd_len < 1 ||  mgmtd_len > 32) {
+       ND_PRINT((ndo, " [invalid MgmtD Len %d]", mgmtd_len));
+       return;
+    }
+    fn_printzp(ndo, tptr + 4, mgmtd_len, NULL);
     ND_PRINT((ndo, ", %s: %u",
           tok2str(vtp_header_values, "Unknown", type),
           *(tptr+2)));
@@ -161,7 +166,7 @@ vtp_print (netdissect_options *ndo,
         *
         *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        *  |     Version   |     Code      |    Followers  |    MmgtD Len  |
+        *  |     Version   |     Code      |    Followers  |    MgmtD Len  |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         *  |       Management Domain Name  (zero-padded to 32 bytes)       |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -203,7 +208,7 @@ vtp_print (netdissect_options *ndo,
         *
         *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        *  |     Version   |     Code      |   Seq number  |    MmgtD Len  |
+        *  |     Version   |     Code      |   Seq number  |    MgmtD Len  |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         *  |       Management Domain Name  (zero-padded to 32 bytes)       |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -342,7 +347,7 @@ vtp_print (netdissect_options *ndo,
         *
         *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-        *  |     Version   |     Code      |   Reserved    |    MmgtD Len  |
+        *  |     Version   |     Code      |   Reserved    |    MgmtD Len  |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         *  |       Management Domain Name  (zero-padded to 32 bytes)       |
         *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+