aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-smb-sidsnooping.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-06-28 07:35:00 -0700
committerMichael Mann <mmann78@netscape.net>2015-07-03 23:36:37 +0000
commit7ce77c69ea4f3424616558729ec23cf3dd1de694 (patch)
treebf3310cb4eb6fccb7dcc29297ef49732a108bdc9 /epan/dissectors/packet-smb-sidsnooping.c
parentf5340b2a07a0a5f6830a091283d3170195203b82 (diff)
Split four more init routines into init/cleanup
Three of them are trivial movements, the smb-sidsnooping is an odd one. Ronnie Sahlberg disabled the sid_name_snooping feature on 9 July 2007. There is a preference to override it though... For now add a TODO marker and ensure that the hash tables are always initialized. Change-Id: I61f5e215c9fa72a6785fb48eaa2d50c1975d7483 Reviewed-on: https://code.wireshark.org/review/9227 Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-smb-sidsnooping.c')
-rw-r--r--epan/dissectors/packet-smb-sidsnooping.c47
1 files changed, 16 insertions, 31 deletions
diff --git a/epan/dissectors/packet-smb-sidsnooping.c b/epan/dissectors/packet-smb-sidsnooping.c
index fdcade96bc..52328bc2da 100644
--- a/epan/dissectors/packet-smb-sidsnooping.c
+++ b/epan/dissectors/packet-smb-sidsnooping.c
@@ -259,20 +259,13 @@ lsa_policy_information(void *dummy _U_, packet_info *pinfo _U_, epan_dissect_t *
return 0;
}
-static gboolean
-free_all_sid_names(gpointer key_arg, gpointer value _U_, gpointer user_data _U_)
+static void
+sid_name_key_destroy(gpointer key_arg)
{
sid_name *sn = (sid_name *)key_arg;
- if(sn->sid){
- g_free((gpointer)sn->sid);
- sn->sid=NULL;
- }
- if(sn->name){
- g_free((gpointer)sn->name);
- sn->name=NULL;
- }
- return TRUE;
+ g_free((gpointer)sn->sid);
+ g_free((gpointer)sn->name);
}
static gint
@@ -298,11 +291,6 @@ sid_name_hash(gconstpointer k)
}
-static gboolean
-free_all_ctx_handle(gpointer key_arg _U_, gpointer value _U_, gpointer user_data _U_)
-{
- return TRUE;
-}
static gint
ctx_handle_equal(gconstpointer k1, gconstpointer k2)
{
@@ -335,17 +323,10 @@ sid_snooping_init(void)
samr_query_dispinfo_tap_installed=FALSE;
}
- if(sid_name_table){
- g_hash_table_foreach_remove(sid_name_table, free_all_sid_names, NULL);
- sid_name_table=NULL;
- }
- if(ctx_handle_table){
- g_hash_table_foreach_remove(ctx_handle_table, free_all_ctx_handle, NULL);
- ctx_handle_table=NULL;
- }
-
-
-/* this code needs to be rewritten from scratch
+ sid_name_table = g_hash_table_new_full(sid_name_hash, sid_name_equal,
+ sid_name_key_destroy, NULL);
+ ctx_handle_table = g_hash_table_new(ctx_handle_hash, ctx_handle_equal);
+/* TODO this code needs to be rewritten from scratch
disabling it now so that it won't cause wireshark to abort due to
unknown hf fields
*/
@@ -355,10 +336,6 @@ sid_name_snooping=FALSE;
return;
}
- sid_name_table=g_hash_table_new(sid_name_hash, sid_name_equal);
-
-
- ctx_handle_table=g_hash_table_new(ctx_handle_hash, ctx_handle_equal);
#if 0
@@ -403,10 +380,18 @@ sid_name_snooping=FALSE;
samr_query_dispinfo_tap_installed=TRUE;
}
+static void
+sid_snooping_cleanup(void)
+{
+ g_hash_table_destroy(sid_name_table);
+ g_hash_table_destroy(ctx_handle_table);
+}
+
void
proto_register_smb_sidsnooping(void)
{
register_init_routine(sid_snooping_init);
+ register_cleanup_routine(sid_snooping_cleanup);
}
/*