From 315bba7c645b75af24215c6303d187b188610bba Mon Sep 17 00:00:00 2001 From: Pascal Quantin Date: Tue, 16 Aug 2016 23:11:12 +0200 Subject: [PATCH] FP: ensure that mac and rlc structures are always allocated Rather han checking everywhere that the RLC and MAC info are present in pinfo, allocate a temporary structure that will be dropped once packet dissection is over. Bug: 12751 Change-Id: I890430dd0c0b56d641777c15eedbf07fef082904 Reviewed-on: https://code.wireshark.org/review/17094 Petri-Dish: Pascal Quantin Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin --- epan/dissectors/packet-umts_fp.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/epan/dissectors/packet-umts_fp.c b/epan/dissectors/packet-umts_fp.c index 5552e0ccee..893c17201a 100644 --- a/epan/dissectors/packet-umts_fp.c +++ b/epan/dissectors/packet-umts_fp.c @@ -2724,9 +2724,7 @@ dissect_e_dch_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ddi_ti = proto_tree_add_bits_ret_val(subframe_header_tree, hf_fp_edch_ddi, tvb, offset*8 + bit_offset, 6, &ddi, ENC_BIG_ENDIAN); - if (rlcinf) { - rlcinf->rbid[i] = (guint8)ddi; - } + rlcinf->rbid[i] = (guint8)ddi; /********************************/ /* Look up data in higher layers*/ /* Look up the size from this DDI value */ @@ -2775,6 +2773,9 @@ dissect_e_dch_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bit_offset = 0; macinf = (umts_mac_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0); + if (!macinf) { + macinf = wmem_new0(wmem_packet_scope(), umts_mac_info); + } /* Add subframe subtree */ subframe_ti = proto_tree_add_string_format(tree, hf_fp_edch_subframe, tvb, offset, 0, "", "Subframe %u data", subframes[n].subframe_number); @@ -3170,7 +3171,13 @@ dissect_hsdsch_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, rlc_info *rlcinf; rlcinf = (rlc_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0); + if (!rlcinf) { + rlcinf = wmem_new0(wmem_packet_scope(), rlc_info); + } macinf = (umts_mac_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0); + if (!macinf) { + macinf = wmem_new0(wmem_packet_scope(), umts_mac_info); + } /**************************************/ /* HS-DCH data here (type 1 in R7) */ @@ -3373,7 +3380,14 @@ dissect_hsdsch_type_2_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree rlc_info *rlcinf; rlcinf = (rlc_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0); + if (!rlcinf) { + rlcinf = wmem_new0(wmem_packet_scope(), rlc_info); + } macinf = (umts_mac_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0); + if (!macinf) { + macinf = wmem_new0(wmem_packet_scope(), umts_mac_info); + } + /********************************/ /* HS-DCH type 2 data here */ @@ -3616,7 +3630,13 @@ void dissect_hsdsch_common_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto rlc_info *rlcinf; rlcinf = (rlc_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0); + if (!rlcinf) { + rlcinf = wmem_new0(wmem_packet_scope(), rlc_info); + } macinf = (umts_mac_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_umts_mac, 0); + if (!macinf) { + macinf = wmem_new0(wmem_packet_scope(), umts_mac_info); + } /********************************/ /* HS-DCH type 2 data here */ @@ -4318,6 +4338,9 @@ dissect_fp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat } rlcinf = (rlc_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_rlc, 0); + if (!rlcinf) { + rlcinf = wmem_new0(wmem_packet_scope(), rlc_info); + } /* Show release information */ if (preferences_show_release_info) {