dof: clean up adding the session key to the dissection.

Let the libwireshark code format the value of the session key, by
setting its display format to SEP_COLON.

Use proto_tree_add_bytes_with_length(), so that the session key becomes
the value of the field; otherwise, the length of the key isn't
specified.

This means we don't need to call bytestring_to_str() (the code in
epan/proto.c calls it for us).

This also plugs a leak of the string generated by bytestring_to_str().
This commit is contained in:
Guy Harris 2021-05-22 03:00:39 -07:00
parent c01456b77e
commit 66accecf3e
1 changed files with 2 additions and 3 deletions

View File

@ -9460,8 +9460,7 @@ static int dissect_tep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
/* Add a field to show the session key that has been learned. */
if (rekey_data->key_data && rekey_data->key_data->session_key && tep_tree)
{
const gchar *SID = bytestring_to_str(NULL, rekey_data->key_data->session_key, 32, ':');
ti = proto_tree_add_bytes_format_value(tree, hf_tep_session_key, tvb, 0, 0, rekey_data->key_data->session_key, "%s", SID);
ti = proto_tree_add_bytes_with_length(tree, hf_tep_session_key, tvb, 0, 0, rekey_data->key_data->session_key, 32);
proto_item_set_generated(ti);
}
@ -11989,7 +11988,7 @@ static void dof_register_tep_128(void)
{ "Initial State", "dof.2008.4.tep1.2.2.1.initial_state", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL } },
{ &hf_tep_session_key,
{ "Session Key", "dof.session_key", FT_BYTES, BASE_NONE, NULL, 0x00, NULL, HFILL } },
{ "Session Key", "dof.session_key", FT_BYTES, SEP_COLON, NULL, 0x00, NULL, HFILL } },
};
static gint *ett[] =