aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2017-09-29 23:31:48 +0100
committerJoão Valverde <j@v6e.pt>2017-09-30 11:59:31 +0000
commitcf79a87705c3b22233b252705bb3570ce357bbd4 (patch)
tree86ac7af222a072fa4a7fd103d397b7a1a61448d3 /plugins
parentbf580c066a52ce86226f40cfb32a48a819c160f8 (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.c4
-rw-r--r--plugins/wimax/mac_hd_type1_decoder.c5
-rw-r--r--plugins/wimax/mac_hd_type2_decoder.c5
-rw-r--r--plugins/wimax/packet-wmx.c19
-rw-r--r--plugins/wimax/wimax-int.h39
-rw-r--r--plugins/wimax/wimax_cdma_code_decoder.c5
-rw-r--r--plugins/wimax/wimax_compact_dlmap_ie_decoder.c5
-rw-r--r--plugins/wimax/wimax_compact_ulmap_ie_decoder.c5
-rw-r--r--plugins/wimax/wimax_fch_decoder.c5
-rw-r--r--plugins/wimax/wimax_ffb_decoder.c5
-rw-r--r--plugins/wimax/wimax_hack_decoder.c5
-rw-r--r--plugins/wimax/wimax_harq_map_decoder.c5
-rw-r--r--plugins/wimax/wimax_pdu_decoder.c4
-rw-r--r--plugins/wimax/wimax_phy_attributes_decoder.c5
-rw-r--r--plugins/wimax/wimax_utils.c5
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 2f5a7f9..55f5a8a 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 fdc3e63..50a9178 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 c45a88b..4cb74c9 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 c71dafc..89aded3 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 0000000..9141d92
--- /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 1f85a97..b9b504f 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 af5785b..4016aca 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 f950399..0e3adfd 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 2ba8077..80de85e 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 1723179..4e1ea99 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 f2b83d8..db24c2b 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 ba94f3e..8eaf381 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 4d7a9cc..a9f097f 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 24914fd..e1fa8d0 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 fbe7704..e1cd8ca 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[] =