From: Francois-Xavier Le Bail Date: Tue, 10 Nov 2015 12:28:17 +0000 (+0100) Subject: VTP: Filter out non-printable characters X-Git-Tag: tcpdump-4.8.0~75 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/dee95f4fb45cf98b2d15d43fc90391c6ca3b7f3a VTP: Filter out non-printable characters Use fn_printzp(). Moreover: Improve some comments. Use 'type' instead of '*(tptr+1)' when possible. --- diff --git a/print-vtp.c b/print-vtp.c index cba34a6c..ce8cdac7 100644 --- a/print-vtp.c +++ b/print-vtp.c @@ -135,7 +135,7 @@ vtp_print (netdissect_options *ndo, ND_PRINT((ndo, "VTPv%u, Message %s (0x%02x), length %u", *tptr, tok2str(vtp_message_type_values,"Unknown message type", type), - *(tptr+1), + type, length)); /* In non-verbose mode, just print version and message type */ @@ -144,9 +144,10 @@ vtp_print (netdissect_options *ndo, } /* verbose mode print all fields */ - ND_PRINT((ndo, "\n\tDomain name: %s, %s: %u", - (tptr+4), - tok2str(vtp_header_values,"Unknown",*(tptr+1)), + ND_PRINT((ndo, "\n\tDomain name: ")); + fn_printzp(ndo, tptr + 4, *(tptr + 3), NULL); + ND_PRINT((ndo, ", %s: %u", + tok2str(vtp_header_values, "Unknown", type), *(tptr+2))); tptr += VTP_HEADER_LEN; @@ -162,7 +163,7 @@ vtp_print (netdissect_options *ndo, * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Version | Code | Followers | MmgtD Len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Management Domain Name | + * | Management Domain Name (zero-padded to 32 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Configuration revision number | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ @@ -201,7 +202,7 @@ vtp_print (netdissect_options *ndo, * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Version | Code | Seq number | MmgtD Len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Management Domain Name | + * | Management Domain Name (zero-padded to 32 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Configuration revision number | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ @@ -241,13 +242,13 @@ vtp_print (netdissect_options *ndo, ND_TCHECK2(*tptr, len); vtp_vlan = (const struct vtp_vlan_*)tptr; - ND_PRINT((ndo, "\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name %s", + ND_PRINT((ndo, "\n\tVLAN info status %s, type %s, VLAN-id %u, MTU %u, SAID 0x%08x, Name ", tok2str(vtp_vlan_status,"Unknown",vtp_vlan->status), tok2str(vtp_vlan_type_values,"Unknown",vtp_vlan->type), EXTRACT_16BITS(&vtp_vlan->vlanid), EXTRACT_16BITS(&vtp_vlan->mtu), - EXTRACT_32BITS(&vtp_vlan->index), - (tptr + VTP_VLAN_INFO_OFFSET))); + EXTRACT_32BITS(&vtp_vlan->index))); + fn_printzp(ndo, tptr + VTP_VLAN_INFO_OFFSET, vtp_vlan->name_len, NULL); /* * Vlan names are aligned to 32-bit boundaries. @@ -339,7 +340,7 @@ vtp_print (netdissect_options *ndo, * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Version | Code | Reserved | MmgtD Len | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - * | Management Domain Name | + * | Management Domain Name (zero-padded to 32 bytes) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Start value | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+