Handle dissectors that don't have names.

Dissector handles created with create_dissector_handle() don't have a
name; report them as "(anonymous)" (there's no guarantee that the printf
family of routines don't crash when a null pointer is provided to %s -
the printf routines in at least some versions of Solaris *do* crash in
that case).

Change-Id: I561ff855a46eeb442299011d567f20751c5c6869
Reviewed-on: https://code.wireshark.org/review/16399
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2016-07-12 11:25:49 -07:00
parent 719c018f27
commit fea50cc4d6
1 changed files with 9 additions and 2 deletions

View File

@ -1794,9 +1794,16 @@ dissector_add_for_decode_as(const char *name, dissector_handle_t handle)
dup_handle = (dissector_handle_t)entry->data;
if (dup_handle->protocol == handle->protocol)
{
const char *dissector_name, *dup_dissector_name;
dissector_name = dissector_handle_get_dissector_name(handle);
if (dissector_name == NULL)
dissector_name = "(anonymous)";
dup_dissector_name = dissector_handle_get_dissector_name(dup_handle);
if (dup_dissector_name == NULL)
dup_dissector_name = "(anonymous)";
fprintf(stderr, "Duplicate dissectors %s and %s for protocol %s in dissector table %s\n",
dissector_handle_get_dissector_name(handle),
dissector_handle_get_dissector_name(dup_handle),
dissector_name, dup_dissector_name,
proto_get_protocol_short_name(handle->protocol),
name);
if (getenv("WIRESHARK_ABORT_ON_DISSECTOR_BUG") != NULL)