aboutsummaryrefslogtreecommitdiffstats
path: root/epan/epan.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-10-27 17:41:23 -0700
committerGuy Harris <guy@alum.mit.edu>2015-10-28 00:44:26 +0000
commitc7e42be2e5baf0a5f351b126cdac5c3d6d9241a0 (patch)
treef0e307a13ade2b261f181b9a58865a17aea00a02 /epan/epan.c
parent2831d391eff4a08f515effe2f1b20d659e1046ee (diff)
Catch REPORT_DISSECTOR_BUG() calls in dissector registration routines.
Have epan_init() return a success/failure Boolean indication. Catch exceptions when calling the dissector registration routines and, if we get one, report the error and return a failure indication. If epan_init() fails, quit, but first make sure the reported error is displayed. Change-Id: I0300cbb1f66a5644f857a205235124909d684c50 Reviewed-on: https://code.wireshark.org/review/11340 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/epan.c')
-rw-r--r--epan/epan.c56
1 files changed, 43 insertions, 13 deletions
diff --git a/epan/epan.c b/epan/epan.c
index 4fb797dbd7..df4dd17ef7 100644
--- a/epan/epan.c
+++ b/epan/epan.c
@@ -21,6 +21,8 @@
#include "config.h"
+#include <stdarg.h>
+
#ifdef HAVE_LIBGCRYPT
#include <wsutil/wsgcrypt.h>
#endif /* HAVE_LIBGCRYPT */
@@ -31,6 +33,10 @@
#include <glib.h>
+#include <wsutil/report_err.h>
+
+#include <epan/exceptions.h>
+
#include "epan-int.h"
#include "epan.h"
#include "dfilter/dfilter.h"
@@ -85,12 +91,14 @@ epan_register_plugin_types(void)
#endif
}
-void
+gboolean
epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data),
void (*register_all_handoffs_func)(register_cb cb, gpointer client_data),
register_cb cb,
gpointer client_data)
{
+ gboolean status = TRUE;
+
/* initialize memory allocation subsystem */
wmem_init();
@@ -110,20 +118,42 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da
#ifdef HAVE_LIBGNUTLS
gnutls_global_init();
#endif
- tap_init();
- prefs_init();
- expert_init();
- packet_init();
- proto_init(register_all_protocols_func, register_all_handoffs_func,
- cb, client_data);
- packet_cache_proto_handles();
- dfilter_init();
- final_registration_all_protocols();
- print_cache_field_handles();
- expert_packet_init();
+ TRY {
+ tap_init();
+ prefs_init();
+ expert_init();
+ packet_init();
+ proto_init(register_all_protocols_func, register_all_handoffs_func,
+ cb, client_data);
+ packet_cache_proto_handles();
+ dfilter_init();
+ final_registration_all_protocols();
+ print_cache_field_handles();
+ expert_packet_init();
#ifdef HAVE_LUA
- wslua_init(cb, client_data);
+ wslua_init(cb, client_data);
#endif
+ }
+ CATCH(DissectorError) {
+ /*
+ * This is probably a dissector, or something it calls,
+ * calling REPORT_DISSECTOR_ERROR() in a registration
+ * routine or something else outside the normal dissection
+ * code path.
+ */
+ const char *exception_message = GET_MESSAGE;
+ static const char dissector_error_nomsg[] =
+ "Dissector writer didn't bother saying what the error was";
+
+ report_failure("Dissector bug: %s",
+ exception_message == NULL ?
+ dissector_error_nomsg : exception_message);
+ if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)
+ abort();
+ status = FALSE;
+ }
+ ENDTRY;
+ return status;
}
void