diff options
author | Guy Harris <guy@alum.mit.edu> | 2004-02-28 20:59:23 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2004-02-28 20:59:23 +0000 |
commit | 7b7c0c23613007fb150f03dd4b15d7f0ed2a1c24 (patch) | |
tree | 57bac93efc52f43853c89b361defe01f5a78479b /epan | |
parent | b151b6d215eb4bcb5766742de858a4ff0d6b3ba0 (diff) | |
download | wireshark-7b7c0c23613007fb150f03dd4b15d7f0ed2a1c24.tar.gz |
Not all dissector handles have protocols associated with them; check for
that before handing a null protocol handle to another routine.
svn path=/trunk/; revision=10258
Diffstat (limited to 'epan')
-rw-r--r-- | epan/packet.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/epan/packet.c b/epan/packet.c index f132604781..5bbe57ee36 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.102 2004/02/24 09:40:38 sahlberg Exp $ + * $Id: packet.c,v 1.103 2004/02/28 20:59:23 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1484,17 +1484,37 @@ register_heur_dissector_list(const char *name, heur_dissector_list_t *sub_dissec */ static GHashTable *registered_dissectors = NULL; -/* Get the short name of the protocol for a dissector handle. */ +/* Get the short name of the protocol for a dissector handle, if it has + a protocol. */ char * dissector_handle_get_short_name(dissector_handle_t handle) { + if (handle->protocol == NULL) { + /* + * No protocol (see, for example, the handle for + * dissecting the set of protocols where the first + * octet of the payload is an OSI network layer protocol + * ID). + */ + return NULL; + } return proto_get_protocol_short_name(handle->protocol); } -/* Get the index of the protocol for a dissector handle. */ +/* Get the index of the protocol for a dissector handle, if it has + a protocol. */ int dissector_handle_get_protocol_index(dissector_handle_t handle) { + if (handle->protocol == NULL) { + /* + * No protocol (see, for example, the handle for + * dissecting the set of protocols where the first + * octet of the payload is an OSI network layer protocol + * ID). + */ + return -1; + } return proto_get_id(handle->protocol); } |