From 74541a9596eead6647c592de9aa46797c2dffa84 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Thu, 29 Oct 2015 09:23:55 -0400 Subject: Don't allow multiple registrations of a protocol in dissector tables. The target here is the Decode As dialog where protocols have multiple registrations into a dissector table and that shows up as multiple entries in the Decode As dialog list with the same name so users are unsure which "dissector" they are choosing. The "default" behavior (done in this commit) is to not allow duplicates for a dissector table, whether its part of Decode As or not. It's just ENFORCED for Decode As. Bug: 3949 Change-Id: Ibe14fa61aaeca0881f9cc39b78799e314b5e8127 Reviewed-on: https://code.wireshark.org/review/11405 Petri-Dish: Michael Mann Reviewed-by: Michael Mann --- epan/decode_as.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'epan/decode_as.c') diff --git a/epan/decode_as.c b/epan/decode_as.c index f66f17ca19..3f9c63d129 100644 --- a/epan/decode_as.c +++ b/epan/decode_as.c @@ -26,16 +26,40 @@ #include "decode_as.h" #include "packet.h" +#include +#include GList *decode_as_list = NULL; void register_decode_as(decode_as_t* reg) { + dissector_table_t decode_table; + /* Ensure valid functions */ DISSECTOR_ASSERT(reg->populate_list); DISSECTOR_ASSERT(reg->reset_value); DISSECTOR_ASSERT(reg->change_value); + /* Ensure the dissector table can't have duplicate protocols + that could confuse users */ + decode_table = find_dissector_table(reg->table_name); + /* XXX - This should really be a DISSECTOR_ASSERT but a Bluetooth + * dissector is registering for "media_type" dissector table before it + * can be created + * There is also the "fake" DCE/RPC dissector table that needs to be fixed + */ + if (decode_table != NULL) + { + /* FT_STRING can at least show the string value in the dialog, so don't penalize them */ + if ((dissector_table_get_type(decode_table) != FT_STRING) && + (dissector_table_get_proto_allowed(decode_table) != DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE)) + { + fprintf(stderr, "%s allows duplicates, which can lead to confuse in the Decode As dialog\n", reg->table_name); + if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL) + abort(); + } + } + decode_as_list = g_list_append(decode_as_list, reg); } -- cgit v1.2.1