summaryrefslogtreecommitdiff
path: root/epan/decode_as.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-10-29 09:23:55 -0400
committerMichael Mann <mmann78@netscape.net>2015-11-04 12:39:40 +0000
commit74541a9596eead6647c592de9aa46797c2dffa84 (patch)
tree7962802ba44900541a93a77f2d4923e2d4daebf2 /epan/decode_as.c
parent0ccab3c0b54ce82a5e5036894194ab25c9ea18d4 (diff)
downloadwireshark-74541a9596eead6647c592de9aa46797c2dffa84.tar.gz
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 <mmann78@netscape.net> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/decode_as.c')
-rw-r--r--epan/decode_as.c24
1 files changed, 24 insertions, 0 deletions
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 <stdio.h>
+#include <stdlib.h>
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);
}