diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2016-06-19 11:01:56 +0200 |
---|---|---|
committer | Pascal Quantin <pascal.quantin@gmail.com> | 2016-06-19 10:47:10 +0000 |
commit | a383e692c8774c2451a55d8b3f8ef9db5d037329 (patch) | |
tree | ab6223527915ab1127a50563981816adc18b971f /epan | |
parent | ff845123f1f1ecef0d8e0d8980e6e9d7267e5f6b (diff) |
Revert "tap: change glib functions to wmem."
This reverts commit 2e9f3c5d366eaa7139fc877b5301392166b3f985.
It breaks the registration of codec, dissector and libwiretap plugins.
Change-Id: I4ef91dd192f765adf87ea9fe9f3693e25dbd24de
Reviewed-on: https://code.wireshark.org/review/16012
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/packet-smb-sidsnooping.c | 10 | ||||
-rw-r--r-- | epan/dissectors/packet-smb.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-smb2.c | 4 | ||||
-rw-r--r-- | epan/epan.c | 14 | ||||
-rw-r--r-- | epan/tap.c | 48 | ||||
-rw-r--r-- | epan/tap.h | 8 | ||||
-rw-r--r-- | epan/wslua/wslua_field.c | 6 | ||||
-rw-r--r-- | epan/wslua/wslua_listener.c | 6 |
8 files changed, 44 insertions, 56 deletions
diff --git a/epan/dissectors/packet-smb-sidsnooping.c b/epan/dissectors/packet-smb-sidsnooping.c index 15adff8033..3a2ff1628c 100644 --- a/epan/dissectors/packet-smb-sidsnooping.c +++ b/epan/dissectors/packet-smb-sidsnooping.c @@ -263,7 +263,7 @@ ctx_handle_hash(gconstpointer k) static void sid_snooping_init(void) { - gchar *error_string; + GString *error_string; if(lsa_policy_information_tap_installed){ remove_tap_listener(&lsa_policy_information_tap_installed); @@ -310,8 +310,8 @@ sid_name_snooping=FALSE; /* error, we failed to attach to the tap. clean up */ report_failure( "Couldn't register proto_reg_handoff_smb_sidsnooping()/lsa_policy_information tap: %s\n", - error_string); - wmem_free(NULL, error_string); + error_string->str); + g_string_free(error_string, TRUE); return; } lsa_policy_information_tap_installed=TRUE; @@ -324,8 +324,8 @@ sid_name_snooping=FALSE; /* error, we failed to attach to the tap. clean up */ report_failure( "Couldn't register proto_reg_handoff_smb_sidsnooping()/samr_query_dispinfo tap: %s\n", - error_string); - wmem_free(NULL, error_string); + error_string->str); + g_string_free(error_string, TRUE); return; } samr_query_dispinfo_tap_installed=TRUE; diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c index a73662833f..9ce5fb651e 100644 --- a/epan/dissectors/packet-smb.c +++ b/epan/dissectors/packet-smb.c @@ -6887,7 +6887,7 @@ dissect_session_setup_andx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree const ntlmssp_header_t *ntlmssph; if (!ntlmssp_tap_id) { - gchar *error_string; + GString *error_string; /* We don't specify any callbacks at all. * Instead we manually fetch the tapped data after the * security blob has been fully dissected and before @@ -6898,7 +6898,7 @@ dissect_session_setup_andx_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree if (!error_string) { ntlmssp_tap_id = find_tap_id("ntlmssp"); } else { - wmem_free(NULL, error_string); + g_string_free(error_string, TRUE); } } diff --git a/epan/dissectors/packet-smb2.c b/epan/dissectors/packet-smb2.c index a8f1ebe810..7e82d2cbdd 100644 --- a/epan/dissectors/packet-smb2.c +++ b/epan/dissectors/packet-smb2.c @@ -2772,7 +2772,7 @@ dissect_smb2_session_setup_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree int idx; if (!ntlmssp_tap_id) { - gchar *error_string; + GString *error_string; /* We don't specify any callbacks at all. * Instead we manually fetch the tapped data after the * security blob has been fully dissected and before @@ -2783,7 +2783,7 @@ dissect_smb2_session_setup_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree if (!error_string) { ntlmssp_tap_id = find_tap_id("ntlmssp"); } else { - wmem_free(NULL, error_string); + g_string_free(error_string, TRUE); } } diff --git a/epan/epan.c b/epan/epan.c index 82c5168297..0927172570 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -24,7 +24,6 @@ #include <stdarg.h> #include <wsutil/wsgcrypt.h> -#include <wsutil/plugins.h> #ifdef HAVE_LIBGNUTLS #include <gnutls/gnutls.h> @@ -119,12 +118,6 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da #ifdef HAVE_LIBGNUTLS gnutls_global_init(); #endif - -#ifdef HAVE_PLUGINS - /* Register all the plugin types we have. */ - epan_register_plugin_types(); /* Types known to libwireshark */ -#endif - TRY { tap_init(); prefs_init(); @@ -162,13 +155,6 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da status = FALSE; } ENDTRY; - -#ifdef HAVE_PLUGINS - /* Scan for plugins. This does *not* call their registration routines; - that's done later. */ - scan_plugins(); -#endif - return status; } diff --git a/epan/tap.c b/epan/tap.c index 129223fc0e..1348e375dd 100644 --- a/epan/tap.c +++ b/epan/tap.c @@ -39,7 +39,6 @@ #include <epan/packet_info.h> #include <epan/dfilter/dfilter.h> #include <epan/tap.h> -#include <epan/wmem/wmem_list.h> static gboolean tapping_is_active=FALSE; @@ -119,7 +118,7 @@ typedef struct { void (*register_tap_listener_fn)(void); /* routine to call to register tap listener */ } tap_plugin; -static wmem_list_t *tap_plugins = NULL; +static GSList *tap_plugins = NULL; /* * Callback for each plugin found. @@ -149,9 +148,9 @@ DIAG_ON(pedantic) /* * Add this one to the list of tap plugins. */ - plugin = wmem_new(NULL, tap_plugin); + plugin = (tap_plugin *)g_malloc(sizeof (tap_plugin)); plugin->register_tap_listener_fn = register_tap_listener_fn; - wmem_list_append(tap_plugins, plugin); + tap_plugins = g_slist_append(tap_plugins, plugin); return TRUE; } @@ -175,7 +174,7 @@ register_tap_plugin_listener(gpointer data, gpointer user_data _U_) void register_all_plugin_tap_listeners(void) { - wmem_list_foreach(tap_plugins, register_tap_plugin_listener, NULL); + g_slist_foreach(tap_plugins, register_tap_plugin_listener, NULL); } #endif /* HAVE_PLUGINS */ @@ -189,7 +188,6 @@ void tap_init(void) { tap_packet_index=0; - tap_plugins = wmem_list_new(NULL); } /* ********************************************************************** @@ -224,9 +222,9 @@ register_tap(const char *name) return tap_id; } - td=wmem_new(NULL, tap_dissector_t); + td=(tap_dissector_t *)g_malloc(sizeof(tap_dissector_t)); td->next=NULL; - td->name = wmem_strdup(NULL, name); + td->name = g_strdup(name); if(!tap_dissector_list){ tap_dissector_list=td; @@ -508,8 +506,10 @@ free_tap_listener(volatile tap_listener_t *tl) if(tl->code){ dfilter_free(tl->code); } - wmem_free(NULL, tl->fstring); - wmem_free(NULL, (void*)tl); + g_free(tl->fstring); +DIAG_OFF(cast-qual) + g_free((gpointer)tl); +DIAG_ON(cast-qual) } /* this function attaches the tap_listener to the named tap. @@ -518,28 +518,30 @@ free_tap_listener(volatile tap_listener_t *tl) * non-NULL: error, return value points to GString containing error * message. */ -gchar * +GString * register_tap_listener(const char *tapname, void *tapdata, const char *fstring, guint flags, tap_reset_cb reset, tap_packet_cb packet, tap_draw_cb draw) { volatile tap_listener_t *tl; int tap_id; dfilter_t *code=NULL; - gchar *error_string = NULL; + GString *error_string; gchar *err_msg; tap_id=find_tap_id(tapname); if(!tap_id){ - error_string = wmem_strdup_printf(NULL, "Tap %s not found", tapname); + error_string = g_string_new(""); + g_string_printf(error_string, "Tap %s not found", tapname); return error_string; } - tl=wmem_new0(NULL, volatile tap_listener_t); + tl=(volatile tap_listener_t *)g_malloc0(sizeof(tap_listener_t)); tl->needs_redraw=TRUE; tl->flags=flags; if(fstring){ if(!dfilter_compile(fstring, &code, &err_msg)){ - error_string = wmem_strdup_printf(NULL, + error_string = g_string_new(""); + g_string_printf(error_string, "Filter \"%s\" is invalid - %s", fstring, err_msg); g_free(err_msg); @@ -547,7 +549,7 @@ register_tap_listener(const char *tapname, void *tapdata, const char *fstring, return error_string; } } - tl->fstring=wmem_strdup(NULL, fstring); + tl->fstring=g_strdup(fstring); tl->code=code; tl->tap_id=tap_id; @@ -564,12 +566,12 @@ register_tap_listener(const char *tapname, void *tapdata, const char *fstring, /* this function sets a new dfilter to a tap listener */ -gchar * +GString * set_tap_dfilter(void *tapdata, const char *fstring) { volatile tap_listener_t *tl=NULL,*tl2; dfilter_t *code=NULL; - gchar *error_string; + GString *error_string; gchar *err_msg; if(!tap_listener_queue){ @@ -594,19 +596,19 @@ set_tap_dfilter(void *tapdata, const char *fstring) tl->code=NULL; } tl->needs_redraw=TRUE; - wmem_free(NULL, tl->fstring); + g_free(tl->fstring); if(fstring){ if(!dfilter_compile(fstring, &code, &err_msg)){ tl->fstring=NULL; - error_string = wmem_strdup_printf( - NULL, + error_string = g_string_new(""); + g_string_printf(error_string, "Filter \"%s\" is invalid - %s", fstring, err_msg); - wmem_free(NULL, err_msg); + g_free(err_msg); return error_string; } } - tl->fstring=wmem_strdup(NULL, fstring); + tl->fstring=g_strdup(fstring); tl->code=code; } diff --git a/epan/tap.h b/epan/tap.h index c17bafcd5e..c3b427f008 100644 --- a/epan/tap.h +++ b/epan/tap.h @@ -140,8 +140,8 @@ WS_DLL_PUBLIC void draw_tap_listeners(gboolean draw_all); /** this function attaches the tap_listener to the named tap. * function returns : * NULL: ok. - * non-NULL: error, return value points to gchar* containing error - * message. This value must be freed with wmem_free(). + * non-NULL: error, return value points to GString containing error + * message. * @param tapname The name of the tap we want to listen to. * @param tapdata is the instance identifier. The tap system uses the value of this * pointer to distinguish between different instances of a tap. @@ -211,12 +211,12 @@ WS_DLL_PUBLIC void draw_tap_listeners(gboolean draw_all); * or the file has been [re]read completely. */ -WS_DLL_PUBLIC gchar *register_tap_listener(const char *tapname, void *tapdata, +WS_DLL_PUBLIC GString *register_tap_listener(const char *tapname, void *tapdata, const char *fstring, guint flags, tap_reset_cb tap_reset, tap_packet_cb tap_packet, tap_draw_cb tap_draw); /** This function sets a new dfilter to a tap listener */ -WS_DLL_PUBLIC gchar *set_tap_dfilter(void *tapdata, const char *fstring); +WS_DLL_PUBLIC GString *set_tap_dfilter(void *tapdata, const char *fstring); /** This function recompiles dfilter for all registered tap listeners */ WS_DLL_PUBLIC void tap_listeners_dfilter_recompile(void); diff --git a/epan/wslua/wslua_field.c b/epan/wslua/wslua_field.c index 5707300be9..d64513c5a2 100644 --- a/epan/wslua/wslua_field.c +++ b/epan/wslua/wslua_field.c @@ -591,15 +591,15 @@ void lua_prime_all_fields(proto_tree* tree _U_) { if (fake_tap && fake_tap_filter->len > strlen("frame")) { /* a boring tap :-) */ - gchar* error = register_tap_listener("frame", + GString* error = register_tap_listener("frame", &fake_tap, fake_tap_filter->str, 0, /* XXX - do we need the protocol tree or columns? */ NULL, NULL, NULL); if (error) { - report_failure("while registering lua_fake_tap:\n%s", error); - wmem_free(NULL, error); + report_failure("while registering lua_fake_tap:\n%s",error->str); + g_string_free(error,TRUE); } else if (!dfilter_compile(fake_tap_filter->str, &wslua_dfilter, &err_msg)) { report_failure("while compiling dfilter \"%s\" for wslua: %s", fake_tap_filter->str, err_msg); g_free(err_msg); diff --git a/epan/wslua/wslua_listener.c b/epan/wslua/wslua_listener.c index 9d87ee5bbe..85caa7316c 100644 --- a/epan/wslua/wslua_listener.c +++ b/epan/wslua/wslua_listener.c @@ -210,7 +210,7 @@ WSLUA_CONSTRUCTOR Listener_new(lua_State* L) { const gchar* filter = luaL_optstring(L,WSLUA_OPTARG_Listener_new_FILTER,NULL); const gboolean all_fields = wslua_optbool(L, WSLUA_OPTARG_Listener_new_ALLFIELDS, FALSE); Listener tap; - gchar* error; + GString* error; tap = (Listener)g_malloc(sizeof(struct _wslua_tap)); @@ -237,8 +237,8 @@ WSLUA_CONSTRUCTOR Listener_new(lua_State* L) { g_free(tap->name); g_free(tap); /* WSLUA_ERROR(new_tap,"tap registration error"); */ - lua_pushfstring(L,"Error while registering tap:\n%s",error); - wmem_free(NULL, error); + lua_pushfstring(L,"Error while registering tap:\n%s",error->str); + g_string_free(error,TRUE); luaL_error(L,lua_tostring(L,-1)); } |