aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-dtls.c
diff options
context:
space:
mode:
authormorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>2012-02-10 23:08:46 +0000
committermorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>2012-02-10 23:08:46 +0000
commitd88d6417769ceb5439a060215f92358a4162fa80 (patch)
treef792f083d83e35a5df8170ec74c3006ee1c77e4a /epan/dissectors/packet-dtls.c
parentfd1889f27476d77ab6af9cf56bc3792853f1ec0d (diff)
Fix via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6817 :
r40200 made ssl_parse()/dtls_parse() post-update-callbacks for those dissector's UATs so that the dissector would be updated when the user changed the UAT. (This allows SSL/DTLS keys to be taken into account without requiring Wireshark to be restarted.) But, those functions also update the UAT themselves if the old-style keys_list preference is used, creating an infinite recursion. Fix this by splitting the *_parse() functions into two: one for the UAT and one for the old-style keys list. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@40952 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-dtls.c')
-rw-r--r--epan/dissectors/packet-dtls.c65
1 files changed, 39 insertions, 26 deletions
diff --git a/epan/dissectors/packet-dtls.c b/epan/dissectors/packet-dtls.c
index fbfe59a6fb..ead632581a 100644
--- a/epan/dissectors/packet-dtls.c
+++ b/epan/dissectors/packet-dtls.c
@@ -218,19 +218,17 @@ dtls_init(void)
/* parse dtls related preferences (private keys and ports association strings) */
static void
-dtls_parse(void)
+dtls_parse_uat(void)
{
ep_stack_t tmp_stack;
SslAssociation *tmp_assoc;
guint i;
- gchar **old_keys, **parts, *err;
- GString *uat_entry = g_string_new("");
if (dtls_key_hash)
- {
+ {
g_hash_table_foreach(dtls_key_hash, ssl_private_key_free, NULL);
g_hash_table_destroy(dtls_key_hash);
- }
+ }
/* remove only associations created from key list */
tmp_stack = ep_stack_new();
@@ -239,6 +237,31 @@ dtls_parse(void)
ssl_association_remove(dtls_associations, tmp_assoc);
}
+ /* parse private keys string, load available keys and put them in key hash*/
+ dtls_key_hash = g_hash_table_new(ssl_private_key_hash, ssl_private_key_equal);
+
+ ssl_set_debug(dtls_debug_file_name);
+
+ if (ndtlsdecrypt > 0)
+ {
+ for (i = 0; i < ndtlsdecrypt; i++)
+ {
+ ssldecrypt_assoc_t *d = &(dtlskeylist_uats[i]);
+ ssl_parse_key_list(d, dtls_key_hash, dtls_associations, dtls_handle, FALSE);
+ }
+ }
+
+ dissector_add_handle("sctp.port", dtls_handle);
+ dissector_add_handle("udp.port", dtls_handle);
+}
+
+static void
+dtls_parse_old_keys(void)
+{
+ gchar **old_keys, **parts, *err;
+ guint i;
+ GString *uat_entry = g_string_new("");
+
/* Import old-style keys */
if (dtlsdecrypt_uat && dtls_keys_list && dtls_keys_list[0]) {
old_keys = g_strsplit(dtls_keys_list, ";", 0);
@@ -258,23 +281,6 @@ dtls_parse(void)
}
g_string_free(uat_entry, TRUE);
-
- /* parse private keys string, load available keys and put them in key hash*/
- dtls_key_hash = g_hash_table_new(ssl_private_key_hash, ssl_private_key_equal);
-
- ssl_set_debug(dtls_debug_file_name);
-
- if (ndtlsdecrypt > 0)
- {
- for (i = 0; i < ndtlsdecrypt; i++)
- {
- ssldecrypt_assoc_t *d = &(dtlskeylist_uats[i]);
- ssl_parse_key_list(d, dtls_key_hash, dtls_associations, dtls_handle, FALSE);
- }
- }
-
- dissector_add_handle("sctp.port", dtls_handle);
- dissector_add_handle("udp.port", dtls_handle);
}
/*
@@ -2074,6 +2080,8 @@ UAT_FILENAME_CB_DEF(sslkeylist_uats,keyfile,ssldecrypt_assoc_t)
UAT_CSTRING_CB_DEF(sslkeylist_uats,password,ssldecrypt_assoc_t)
#endif
+void proto_reg_handoff_dtls(void);
+
/*********************************************************************
*
* Standard Wireshark Protocol Registration and housekeeping
@@ -2401,7 +2409,7 @@ proto_register_dtls(void)
#ifdef HAVE_LIBGNUTLS
{
- module_t *dtls_module = prefs_register_protocol(proto_dtls, dtls_parse);
+ module_t *dtls_module = prefs_register_protocol(proto_dtls, proto_reg_handoff_dtls);
static uat_field_t dtlskeylist_uats_flds[] = {
UAT_FLD_CSTRING_OTHER(sslkeylist_uats, ipaddr, "IP address", ssldecrypt_uat_fld_ip_chk_cb, "IPv4 or IPv6 address"),
@@ -2423,7 +2431,7 @@ proto_register_dtls(void)
dtlsdecrypt_copy_cb,
NULL, /* dtlsdecrypt_update_cb? */
dtlsdecrypt_free_cb,
- dtls_parse,
+ dtls_parse_uat,
dtlskeylist_uats_flds);
prefs_register_uat_preference(dtls_module, "cfg",
@@ -2466,9 +2474,14 @@ proto_register_dtls(void)
void
proto_reg_handoff_dtls(void)
{
+ static gboolean initialized = FALSE;
/* add now dissector to default ports.*/
- dtls_parse();
+ dtls_parse_uat();
+ dtls_parse_old_keys();
+
+ if (initialized == FALSE)
+ heur_dissector_add("udp", dissect_dtls_heur, proto_dtls);
- heur_dissector_add("udp", dissect_dtls_heur, proto_dtls);
+ initialized = TRUE;
}