diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2016-03-11 20:54:26 +0100 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2016-03-13 10:51:44 +0000 |
commit | 6f220a343e476fb1df1f98c719b0fedf5c4f8c7f (patch) | |
tree | cf194b9f75ad4075bef39b2fb082bcb26ab552a4 | |
parent | b46d55551fbdab486b2142f393b13c56f2ff3204 (diff) | |
download | wireshark-6f220a343e476fb1df1f98c719b0fedf5c4f8c7f.tar.gz wireshark-6f220a343e476fb1df1f98c719b0fedf5c4f8c7f.tar.bz2 wireshark-6f220a343e476fb1df1f98c719b0fedf5c4f8c7f.zip |
Lua: Remove heur dissectors when reload Lua plugins
When reloading Lua plugins all registered heuristic dissectors
must be removed.
Bug: 12251
Change-Id: Ib7da6df347fb9294f5394ae531b582bf6d2730bb
Reviewed-on: https://code.wireshark.org/review/14429
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
-rw-r--r-- | epan/packet.c | 5 | ||||
-rw-r--r-- | epan/wslua/init_wslua.c | 1 | ||||
-rw-r--r-- | epan/wslua/wslua.h | 1 | ||||
-rw-r--r-- | epan/wslua/wslua_proto.c | 16 |
4 files changed, 21 insertions, 2 deletions
diff --git a/epan/packet.c b/epan/packet.c index f8066dedeb..0092097b67 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -2261,14 +2261,15 @@ heur_dissector_delete(const char *name, heur_dissector_t dissector, const int pr g_assert(sub_dissectors != NULL); hdtbl_entry.dissector = dissector; - hdtbl_entry.protocol = find_protocol_by_id(proto); found_entry = g_slist_find_custom(sub_dissectors->dissectors, (gpointer) &hdtbl_entry, find_matching_heur_dissector); if (found_entry) { - g_free(((heur_dtbl_entry_t *)(found_entry->data))->list_name); + heur_dtbl_entry_t *found_hdtbl_entry = (heur_dtbl_entry_t *)(found_entry->data); + g_free(found_hdtbl_entry->list_name); + g_hash_table_remove(heuristic_short_names, (gpointer)found_hdtbl_entry->short_name); g_slice_free(heur_dtbl_entry_t, found_entry->data); sub_dissectors->dissectors = g_slist_delete_link(sub_dissectors->dissectors, found_entry); diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c index 2141dcb947..beacff4f9e 100644 --- a/epan/wslua/init_wslua.c +++ b/epan/wslua/init_wslua.c @@ -978,6 +978,7 @@ void wslua_reload_plugins (register_cb cb, gpointer client_data) { if (ops->close_dialogs) ops->close_dialogs(); + wslua_deregister_heur_dissectors(L); wslua_deregister_protocols(L); wslua_deregister_dissector_tables(L); wslua_deregister_listeners(L); diff --git a/epan/wslua/wslua.h b/epan/wslua/wslua.h index 05c1fa3884..aee0abfda8 100644 --- a/epan/wslua/wslua.h +++ b/epan/wslua/wslua.h @@ -783,6 +783,7 @@ extern int luaopen_rex_glib(lua_State *L); extern const gchar* get_current_plugin_version(void); extern void clear_current_plugin_version(void); +extern int wslua_deregister_heur_dissectors(lua_State* L); extern int wslua_deregister_protocols(lua_State* L); extern int wslua_deregister_dissector_tables(lua_State* L); extern int wslua_deregister_listeners(lua_State* L); diff --git a/epan/wslua/wslua_proto.c b/epan/wslua/wslua_proto.c index bac94d4f46..05131146b5 100644 --- a/epan/wslua/wslua_proto.c +++ b/epan/wslua/wslua_proto.c @@ -583,6 +583,22 @@ ProtoField wslua_is_field_available(lua_State* L, const char* field_abbr) { return NULL; } +int wslua_deregister_heur_dissectors(lua_State* L) { + /* for each registered heur dissector do... */ + lua_rawgeti(L, LUA_REGISTRYINDEX, lua_heur_dissectors_table_ref); + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) { + const gchar *listname = luaL_checkstring(L, -2); + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) { + const gchar *proto_name = luaL_checkstring(L, -2); + int proto_id = proto_get_id_by_short_name(proto_name); + heur_dissector_delete(listname, heur_dissect_lua, proto_id); + } + } + lua_pop(L, 1); /* lua_heur_dissectors_table_ref */ + + return 0; +} + int wslua_deregister_protocols(lua_State* L) { /* for each registered Proto protocol do... */ lua_rawgeti(L, LUA_REGISTRYINDEX, protocols_table_ref); |