Fix some issues with Exported PDUs.

Fix the description in wsutil/exported_pdu_tlvs.h to reflect reality
(i.e., to match what the code in Wireshark that reads the exported PDU
TLVs, and all code that writes them, does).

In the code that dissects them, treat all strings as FT_STRINGZPAD, as
any null bytes at the end of the string are padding, not part of the
string.

See merge request !3895 and issue #17535.
This commit is contained in:
Guy Harris 2021-08-21 02:31:07 -07:00
parent dd161ade12
commit 4de9f6ef83
2 changed files with 31 additions and 30 deletions

View File

@ -416,17 +416,17 @@ proto_register_exported_pdu(void)
}, },
{ &hf_exported_pdu_prot_name, { &hf_exported_pdu_prot_name,
{ "Protocol Name", "exported_pdu.prot_name", { "Protocol Name", "exported_pdu.prot_name",
FT_STRING, BASE_NONE, NULL, 0, FT_STRINGZPAD, BASE_NONE, NULL, 0,
NULL, HFILL } NULL, HFILL }
}, },
{ &hf_exported_pdu_heur_prot_name, { &hf_exported_pdu_heur_prot_name,
{ "Heuristic Protocol Name", "exported_pdu.heur_prot_name", { "Heuristic Protocol Name", "exported_pdu.heur_prot_name",
FT_STRING, BASE_NONE, NULL, 0, FT_STRINGZPAD, BASE_NONE, NULL, 0,
NULL, HFILL } NULL, HFILL }
}, },
{ &hf_exported_pdu_dis_table_name, { &hf_exported_pdu_dis_table_name,
{ "Dissector Table Name", "exported_pdu.dis_table_name", { "Dissector Table Name", "exported_pdu.dis_table_name",
FT_STRING, BASE_NONE, NULL, 0, FT_STRINGZPAD, BASE_NONE, NULL, 0,
NULL, HFILL } NULL, HFILL }
}, },
{ &hf_exported_pdu_p2p_dir, { &hf_exported_pdu_p2p_dir,
@ -506,7 +506,7 @@ proto_register_exported_pdu(void)
}, },
{ &hf_exported_pdu_col_proto_str, { &hf_exported_pdu_col_proto_str,
{ "Column protocol string", "exported_pdu.col_proto_str", { "Column protocol string", "exported_pdu.col_proto_str",
FT_STRING, BASE_NONE, NULL, 0, FT_STRINGZPAD, BASE_NONE, NULL, 0,
NULL, HFILL } NULL, HFILL }
}, },
}; };

View File

@ -20,37 +20,33 @@
* It is a sequence of TLVs; at least one TLV MUST indicate what protocol is * It is a sequence of TLVs; at least one TLV MUST indicate what protocol is
* in the PDU following the TLVs. * in the PDU following the TLVs.
* *
* Each TLV has the form: * Each TLV contains, in order:
* *
* 0 1 2 3 * a 2-byte big-endian type field;
* 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 * a 2-byte big-endian length field;
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * a value, the length of which is indicated by the value of
* | TLV type | TLV length | * the length field (that value does not include the length
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * of the type or length fields themselves).
* / TLV value /
* / variable length /
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* *
* The type and length are both big-endian; the length is the length * TLVs are not guaranteed to be aligned to any particular number
* of the value, and does not include the length of the type and * of bytes.
* length fields.
* *
* The first TLV is of type EXP_PDU_TAG_OPTIONS_LENGTH; its value * The list of TLVs may begin with a TLV of type EXP_PDU_TAG_OPTIONS_LENGTH;
* is a 4-byte integer value, giving the length of all TLVs following * its value is a 4-byte integer value, giving the length of all TLVs
* that TLV (i.e., the length does not include the length of the * following that TLV (i.e., the length does not include the length of
* EXP_PDU_TAG_OPTIONS_LENGTH TLV). * the EXP_PDU_TAG_OPTIONS_LENGTH TLV). This tag is deprecated; it is
* not guaranteed to be present, and code reading packets should not
* require it to be present.
* *
* The last TLV is of type EXP_PDU_TAG_END_OF_OPT; it has a length * The last TLV is of type EXP_PDU_TAG_END_OF_OPT; it has a length
* of 0, and the value is zero-length. * of 0, and the value is zero-length.
* *
* XXX - explain the padding/length rules; this requires reading * For string values, a string may have zero, one, or more null bytes
* all code that writes TLVs, to make sure that the rules don't * at the end; code that reads the string value must not assume that
* disallow any TLVs that might ever have been written by that code, * there are, or are not, null bytes at the end. Null bytes are included
* and reading all code that reads TLVs, to make sure it can handle * in the length field, but are not part of the string value.
* all that code, and to make sure the rules don't allow writing TLVs
* that code can't read.
* *
* This includes the rules for writing strings. * For integral values, the values are in big-endian format.
*/ */
/* Tag values /* Tag values
@ -65,7 +61,9 @@
*/ */
#define EXP_PDU_TAG_END_OF_OPT 0 /**< End-of-options Tag. */ #define EXP_PDU_TAG_END_OF_OPT 0 /**< End-of-options Tag. */
/* 1 - 9 reserved */ /* 1 - 9 reserved */
#define EXP_PDU_TAG_OPTIONS_LENGTH 10 /**< Total length of the options excluding this TLV */ #define EXP_PDU_TAG_OPTIONS_LENGTH 10 /**< Total length of the options excluding this TLV
* Deprecated - do not use
*/
#define EXP_PDU_TAG_LINKTYPE 11 /**< Deprecated - do not use */ #define EXP_PDU_TAG_LINKTYPE 11 /**< Deprecated - do not use */
#define EXP_PDU_TAG_PROTO_NAME 12 /**< The value part should be an ASCII non NULL terminated string #define EXP_PDU_TAG_PROTO_NAME 12 /**< The value part should be an ASCII non NULL terminated string
* of the registered dissector used by Wireshark e.g "sip" * of the registered dissector used by Wireshark e.g "sip"
@ -126,11 +124,14 @@
* given with tag EXP_PDU_TAG_DISSECTOR_TABLE_NAME, must follow immediately after the table tag. * given with tag EXP_PDU_TAG_DISSECTOR_TABLE_NAME, must follow immediately after the table tag.
*/ */
#define EXP_PDU_TAG_COL_PROT_TEXT 33 /**< Text string to put in COL_PROTOCOL, one use case is in conjunction with dissector tables where #define EXP_PDU_TAG_COL_PROT_TEXT 33 /**< UTF-8 text string to put in COL_PROTOCOL, one use case is in conjunction with dissector tables where
* COL_PROTOCOL might not be filled in. * COL_PROTOCOL might not be filled in.
*/ */
/**< value part is structure passed into TCP subdissectors. Format is: /**< value part is structure passed into TCP subdissectors. The field
begins with a 2-byte version number; if the version number value is
1, the value part is in the form:
version 2 bytes - xport PDU version of structure (for backwards/forwards compatibility) version 2 bytes - xport PDU version of structure (for backwards/forwards compatibility)
seq 4 bytes - Sequence number of first byte in the data seq 4 bytes - Sequence number of first byte in the data
nxtseq 4 bytes - Sequence number of first byte after data nxtseq 4 bytes - Sequence number of first byte after data