From: Francois-Xavier Le Bail Date: Mon, 12 Sep 2016 12:50:29 +0000 (+0200) Subject: VTP: Add a test on Mgmt Domain Name length X-Git-Tag: tcpdump-4.9.0-bp~176 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/a6d5f15cce7c8b9865b93a38f4c074e5aef6d114 VTP: Add a test on Mgmt Domain Name length --- diff --git a/print-vtp.c b/print-vtp.c index a96eeb08..285beb96 100644 --- a/print-vtp.c +++ b/print-vtp.c @@ -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) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+