diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2017-09-29 23:31:48 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2017-09-30 11:59:31 +0000 |
commit | cf79a87705c3b22233b252705bb3570ce357bbd4 (patch) | |
tree | 86ac7af222a072fa4a7fd103d397b7a1a61448d3 /plugins | |
parent | bf580c066a52ce86226f40cfb32a48a819c160f8 (diff) |
WiMAX: Fix possible crash during protocol registration
proto_register_wimax() cannot be assumed to run before all other dissectors
that depend on the global proto_wimax variable. It happens to work now but
registration order is never guaranteed and cannot be relied upon. Wireshark
will crash with a null pointer dereference if proto_register_wimax() is not
run first.
Have proto_register_wimax() call the registration routine for the other dissectors
that depend on proto_wimax to impose the hard-coded order.
Change-Id: I3e9a9ea742f3feeb5b802ad79cfc9ed916264d2f
Reviewed-on: https://code.wireshark.org/review/23788
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/wimax/mac_hd_generic_decoder.c | 4 | ||||
-rw-r--r-- | plugins/wimax/mac_hd_type1_decoder.c | 5 | ||||
-rw-r--r-- | plugins/wimax/mac_hd_type2_decoder.c | 5 | ||||
-rw-r--r-- | plugins/wimax/packet-wmx.c | 19 | ||||
-rw-r--r-- | plugins/wimax/wimax-int.h | 39 | ||||
-rw-r--r-- | plugins/wimax/wimax_cdma_code_decoder.c | 5 | ||||
-rw-r--r-- | plugins/wimax/wimax_compact_dlmap_ie_decoder.c | 5 | ||||
-rw-r--r-- | plugins/wimax/wimax_compact_ulmap_ie_decoder.c | 5 | ||||
-rw-r--r-- | plugins/wimax/wimax_fch_decoder.c | 5 | ||||
-rw-r--r-- | plugins/wimax/wimax_ffb_decoder.c | 5 | ||||
-rw-r--r-- | plugins/wimax/wimax_hack_decoder.c | 5 | ||||
-rw-r--r-- | plugins/wimax/wimax_harq_map_decoder.c | 5 | ||||
-rw-r--r-- | plugins/wimax/wimax_pdu_decoder.c | 4 | ||||
-rw-r--r-- | plugins/wimax/wimax_phy_attributes_decoder.c | 5 | ||||
-rw-r--r-- | plugins/wimax/wimax_utils.c | 5 |
15 files changed, 84 insertions, 37 deletions
diff --git a/plugins/wimax/mac_hd_generic_decoder.c b/plugins/wimax/mac_hd_generic_decoder.c index 2f5a7f9b92..55f5a8a137 100644 --- a/plugins/wimax/mac_hd_generic_decoder.c +++ b/plugins/wimax/mac_hd_generic_decoder.c @@ -43,9 +43,9 @@ #include <epan/expert.h> #include <epan/reassemble.h> #include "crc.h" +#include "wimax-int.h" #include "wimax_utils.h" -void proto_register_mac_header_generic(void); void proto_reg_handoff_mac_header_generic(void); extern gint proto_wimax; @@ -1480,7 +1480,7 @@ static gint arq_feedback_payload_decoder(tvbuff_t *tvb, packet_info *pinfo, prot } /* Register Wimax Generic Mac Header Protocol and Dissector */ -void proto_register_mac_header_generic(void) +void wimax_proto_register_mac_header_generic(void) { /* Generic MAC header display */ static hf_register_info hf[] = diff --git a/plugins/wimax/mac_hd_type1_decoder.c b/plugins/wimax/mac_hd_type1_decoder.c index fdc3e630ee..50a9178710 100644 --- a/plugins/wimax/mac_hd_type1_decoder.c +++ b/plugins/wimax/mac_hd_type1_decoder.c @@ -38,11 +38,10 @@ */ #include <epan/packet.h> +#include "wimax-int.h" extern gint proto_mac_header_generic_decoder; -void proto_register_mac_header_type_1(void); - static gint proto_mac_header_type_1_decoder = -1; static gint ett_mac_header_type_1_decoder = -1; static gint hf_mac_header_type_1_value_bytes = -1; @@ -330,7 +329,7 @@ static int dissect_mac_header_type_1_decoder(tvbuff_t *tvb, packet_info *pinfo, } /* Register Wimax Mac Header Type II Protocol and Dissector */ -void proto_register_mac_header_type_1(void) +void wimax_proto_register_mac_header_type_1(void) { /* TLV display */ static hf_register_info hf[] = diff --git a/plugins/wimax/mac_hd_type2_decoder.c b/plugins/wimax/mac_hd_type2_decoder.c index c45a88b09a..4cb74c96b6 100644 --- a/plugins/wimax/mac_hd_type2_decoder.c +++ b/plugins/wimax/mac_hd_type2_decoder.c @@ -38,11 +38,10 @@ #include "config.h" #include <epan/packet.h> +#include "wimax-int.h" extern gint proto_mac_header_generic_decoder; -void proto_register_mac_header_type_2(void); - static gint proto_mac_header_type_2_decoder = -1; static gint ett_mac_header_type_2_decoder = -1; static gint hf_mac_header_type_2_value_bytes = -1; @@ -789,7 +788,7 @@ static int dissect_mac_header_type_2_decoder(tvbuff_t *tvb, packet_info *pinfo, } /* Register Wimax Mac Header Type II Protocol and Dissector */ -void proto_register_mac_header_type_2(void) +void wimax_proto_register_mac_header_type_2(void) { /* MAC HEADER TYPE II display */ static hf_register_info hf[] = diff --git a/plugins/wimax/packet-wmx.c b/plugins/wimax/packet-wmx.c index c71dafc718..89aded3a99 100644 --- a/plugins/wimax/packet-wmx.c +++ b/plugins/wimax/packet-wmx.c @@ -32,6 +32,7 @@ #include <epan/packet.h> #include <epan/prefs.h> +#include "wimax-int.h" #include "wimax_tlv.h" #include "wimax_utils.h" @@ -330,6 +331,24 @@ void proto_register_wimax(void) &include_cor2_changes); prefs_register_obsolete_preference(wimax_module, "wimax.basic_cid_max"); prefs_register_obsolete_preference(wimax_module, "wimax.corrigendum_2_version"); + + /* + * Call sub-registrations in the correct order because they depend + * on proto_register_wimax() being run first. + */ + wimax_proto_register_wimax_cdma(); + wimax_proto_register_wimax_compact_dlmap_ie(); + wimax_proto_register_wimax_compact_ulmap_ie(); + wimax_proto_register_wimax_fch(); + wimax_proto_register_wimax_ffb(); + wimax_proto_register_wimax_hack(); + wimax_proto_register_wimax_harq_map(); + wimax_proto_register_wimax_pdu(); + wimax_proto_register_wimax_phy_attributes(); + wimax_proto_register_wimax_utility_decoders(); + wimax_proto_register_mac_header_generic(); + wimax_proto_register_mac_header_type_1(); + wimax_proto_register_mac_header_type_2(); } /* diff --git a/plugins/wimax/wimax-int.h b/plugins/wimax/wimax-int.h new file mode 100644 index 0000000000..9141d92abd --- /dev/null +++ b/plugins/wimax/wimax-int.h @@ -0,0 +1,39 @@ +/* wimax-int.h + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1999 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __WIMAX_INT_H__ +#define __WIMAX_INT_H__ + +void wimax_proto_register_wimax_cdma(void); +void wimax_proto_register_wimax_compact_dlmap_ie(void); +void wimax_proto_register_wimax_compact_ulmap_ie(void); +void wimax_proto_register_wimax_fch(void); +void wimax_proto_register_wimax_ffb(void); +void wimax_proto_register_wimax_hack(void); +void wimax_proto_register_wimax_harq_map(void); +void wimax_proto_register_wimax_pdu(void); +void wimax_proto_register_wimax_phy_attributes(void); +void wimax_proto_register_wimax_utility_decoders(void); +void wimax_proto_register_mac_header_generic(void); +void wimax_proto_register_mac_header_type_1(void); +void wimax_proto_register_mac_header_type_2(void); + +#endif
\ No newline at end of file diff --git a/plugins/wimax/wimax_cdma_code_decoder.c b/plugins/wimax/wimax_cdma_code_decoder.c index 1f85a973c9..b9b504f8df 100644 --- a/plugins/wimax/wimax_cdma_code_decoder.c +++ b/plugins/wimax/wimax_cdma_code_decoder.c @@ -29,8 +29,7 @@ #include "config.h" #include <epan/packet.h> - -void proto_register_wimax_cdma(void); +#include "wimax-int.h" static int proto_wimax_cdma_code_decoder = -1; static gint ett_wimax_cdma_code_decoder = -1; @@ -64,7 +63,7 @@ static int dissect_wimax_cdma_code_decoder(tvbuff_t *tvb, packet_info *pinfo, pr } /* Register Wimax CDMA Protocol */ -void proto_register_wimax_cdma(void) +void wimax_proto_register_wimax_cdma(void) { /* TLV display */ static hf_register_info hf[] = diff --git a/plugins/wimax/wimax_compact_dlmap_ie_decoder.c b/plugins/wimax/wimax_compact_dlmap_ie_decoder.c index af5785bd56..4016acab6d 100644 --- a/plugins/wimax/wimax_compact_dlmap_ie_decoder.c +++ b/plugins/wimax/wimax_compact_dlmap_ie_decoder.c @@ -29,6 +29,7 @@ #include "config.h" #include <epan/packet.h> +#include "wimax-int.h" #include "wimax_compact_dlmap_ie_decoder.h" extern gint proto_wimax; @@ -42,8 +43,6 @@ extern gint proto_wimax; #define CID_TYPE_RCID7 2 #define CID_TYPE_RCID3 3 -void proto_register_wimax_compact_dlmap_ie(void); - /* Global Variables */ guint cid_type = 0; guint band_amc_subchannel_type = 0; @@ -1543,7 +1542,7 @@ guint wimax_extended_diuc_dependent_ie_decoder(proto_tree *tree, packet_info *pi } /* Register Wimax Compact DL-MAP IE Protocol */ -void proto_register_wimax_compact_dlmap_ie(void) +void wimax_proto_register_wimax_compact_dlmap_ie(void) { /* Compact DL-MAP IE display */ static hf_register_info hf_compact_dlmap[] = diff --git a/plugins/wimax/wimax_compact_ulmap_ie_decoder.c b/plugins/wimax/wimax_compact_ulmap_ie_decoder.c index f9503990c3..0e3adfdb17 100644 --- a/plugins/wimax/wimax_compact_ulmap_ie_decoder.c +++ b/plugins/wimax/wimax_compact_ulmap_ie_decoder.c @@ -29,6 +29,7 @@ #include "config.h" #include <epan/packet.h> +#include "wimax-int.h" #include "wimax_compact_ulmap_ie_decoder.h" /* MASKs */ @@ -40,8 +41,6 @@ #define CID_TYPE_RCID7 2 #define CID_TYPE_RCID3 3 -void proto_register_wimax_compact_ulmap_ie(void); - /* Global Variables */ extern guint cid_type; extern guint band_amc_subchannel_type; @@ -1496,7 +1495,7 @@ guint wimax_extended_uiuc_dependent_ie_decoder(proto_tree *tree, packet_info *pi } /* Register Wimax Compact UL-MAP IE Protocol */ -void proto_register_wimax_compact_ulmap_ie(void) +void wimax_proto_register_wimax_compact_ulmap_ie(void) { /* Compact UL-MAP IE display */ static hf_register_info hf_compact_ulmap[] = diff --git a/plugins/wimax/wimax_fch_decoder.c b/plugins/wimax/wimax_fch_decoder.c index 2ba8077600..80de85e56d 100644 --- a/plugins/wimax/wimax_fch_decoder.c +++ b/plugins/wimax/wimax_fch_decoder.c @@ -31,13 +31,12 @@ #include <string.h> #include <epan/packet.h> +#include "wimax-int.h" extern gint proto_wimax; extern address bs_address; /* declared in packet-wmx.c */ -void proto_register_wimax_fch(void); - static int proto_wimax_fch_decoder = -1; static gint ett_wimax_fch_decoder = -1; @@ -135,7 +134,7 @@ static int dissect_wimax_fch_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tr } /* Register Wimax FCH Protocol */ -void proto_register_wimax_fch(void) +void wimax_proto_register_wimax_fch(void) { /* TLV display */ static hf_register_info hf[] = diff --git a/plugins/wimax/wimax_ffb_decoder.c b/plugins/wimax/wimax_ffb_decoder.c index 1723179f53..4e1ea997c9 100644 --- a/plugins/wimax/wimax_ffb_decoder.c +++ b/plugins/wimax/wimax_ffb_decoder.c @@ -29,11 +29,10 @@ #include "config.h" #include <epan/packet.h> +#include "wimax-int.h" extern gint proto_wimax; -void proto_register_wimax_ffb(void); - static gint proto_wimax_ffb_decoder = -1; static gint ett_wimax_ffb_decoder = -1; @@ -80,7 +79,7 @@ static int dissect_wimax_ffb_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tr } /* Register Wimax FFB Protocol */ -void proto_register_wimax_ffb(void) +void wimax_proto_register_wimax_ffb(void) { /* FFB display */ static hf_register_info hf[] = diff --git a/plugins/wimax/wimax_hack_decoder.c b/plugins/wimax/wimax_hack_decoder.c index f2b83d8e49..db24c2b5bf 100644 --- a/plugins/wimax/wimax_hack_decoder.c +++ b/plugins/wimax/wimax_hack_decoder.c @@ -29,11 +29,10 @@ #include "config.h" #include <epan/packet.h> +#include "wimax-int.h" extern gint proto_wimax; -void proto_register_wimax_hack(void); - static gint proto_wimax_hack_decoder = -1; static gint ett_wimax_hack_decoder = -1; @@ -93,7 +92,7 @@ static int dissect_wimax_hack_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_t } /* Register Wimax HARQ ACK Protocol */ -void proto_register_wimax_hack(void) +void wimax_proto_register_wimax_hack(void) { /* HARQ ACK display */ static hf_register_info hf[] = diff --git a/plugins/wimax/wimax_harq_map_decoder.c b/plugins/wimax/wimax_harq_map_decoder.c index ba94f3e2bb..8eaf381f25 100644 --- a/plugins/wimax/wimax_harq_map_decoder.c +++ b/plugins/wimax/wimax_harq_map_decoder.c @@ -31,13 +31,12 @@ #include <epan/packet.h> #include <epan/expert.h> #include "crc.h" +#include "wimax-int.h" #include "wimax_compact_dlmap_ie_decoder.h" #include "wimax_compact_ulmap_ie_decoder.h" extern gint proto_wimax; -void proto_register_wimax_harq_map(void); - static gint proto_wimax_harq_map_decoder = -1; static gint ett_wimax_harq_map_decoder = -1; @@ -172,7 +171,7 @@ static int dissector_wimax_harq_map_decoder(tvbuff_t *tvb, packet_info *pinfo, p } /* Register Wimax HARQ MAP Protocol */ -void proto_register_wimax_harq_map(void) +void wimax_proto_register_wimax_harq_map(void) { /* HARQ MAP display */ static hf_register_info hf_harq_map[] = diff --git a/plugins/wimax/wimax_pdu_decoder.c b/plugins/wimax/wimax_pdu_decoder.c index 4d7a9cc3f5..a9f097fc1e 100644 --- a/plugins/wimax/wimax_pdu_decoder.c +++ b/plugins/wimax/wimax_pdu_decoder.c @@ -30,11 +30,11 @@ #include <epan/packet.h> #include "crc.h" +#include "wimax-int.h" #include "wimax_utils.h" extern gint proto_wimax; -void proto_register_wimax_pdu(void); void proto_reg_handoff_wimax_pdu(void); static dissector_handle_t mac_generic_decoder_handle = NULL; @@ -216,7 +216,7 @@ static int dissect_wimax_pdu_decoder(tvbuff_t *tvb, packet_info *pinfo, proto_tr } /* Register Wimax PDU Burst Protocol */ -void proto_register_wimax_pdu(void) +void wimax_proto_register_wimax_pdu(void) { /* PDU display */ static hf_register_info hf[] = diff --git a/plugins/wimax/wimax_phy_attributes_decoder.c b/plugins/wimax/wimax_phy_attributes_decoder.c index 24914fd047..e1fa8d0bc4 100644 --- a/plugins/wimax/wimax_phy_attributes_decoder.c +++ b/plugins/wimax/wimax_phy_attributes_decoder.c @@ -29,11 +29,10 @@ #include "config.h" #include <epan/packet.h> +#include "wimax-int.h" extern gint proto_wimax; -void proto_register_wimax_phy_attributes(void); - static gint proto_wimax_phy_attributes_decoder = -1; static gint ett_wimax_phy_attributes_decoder = -1; @@ -124,7 +123,7 @@ static int dissect_wimax_phy_attributes_decoder(tvbuff_t *tvb, packet_info *pinf } /* Register Wimax PDU Burst Physical Attributes Protocol */ -void proto_register_wimax_phy_attributes(void) +void wimax_proto_register_wimax_phy_attributes(void) { /* Physical Attributes display */ static hf_register_info hf[] = diff --git a/plugins/wimax/wimax_utils.c b/plugins/wimax/wimax_utils.c index fbe77040f9..e1cd8cacb5 100644 --- a/plugins/wimax/wimax_utils.c +++ b/plugins/wimax/wimax_utils.c @@ -32,13 +32,12 @@ #include <epan/packet.h> #include <epan/expert.h> +#include "wimax-int.h" #include "wimax_tlv.h" #include "wimax_mac.h" #include "wimax_utils.h" -void proto_register_wimax_utility_decoders(void); - extern gint proto_mac_mgmt_msg_rng_req_decoder; extern gint proto_mac_mgmt_msg_reg_req_decoder; @@ -704,7 +703,7 @@ static gint hf_common_current_transmitted_power = -1; static expert_field ei_common_tlv_info = EI_INIT; /* Register WiMax Utility Routines */ -void proto_register_wimax_utility_decoders(void) +void wimax_proto_register_wimax_utility_decoders(void) { /* WiMax Service Flow Encodings display */ static hf_register_info hf_sfe[] = |