diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2010-01-25 11:47:39 +0000 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2010-01-25 11:47:39 +0000 |
commit | c198fc65462567cf87c914dc7eff758f18680297 (patch) | |
tree | 03dd1faf270372972f7c1da1e0b81875d16eae54 /epan/dissectors | |
parent | 17a01968d9904dcf2d4a35568755866cec7224ca (diff) |
From Didier Gautheron via bug 4419:
se_alloc and ep_alloc never return NULL and se_alloc0 already initialized
data with 0.
svn path=/trunk/; revision=31654
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/packet-catapult-dct2000.c | 15 | ||||
-rw-r--r-- | epan/dissectors/packet-cip.c | 22 | ||||
-rw-r--r-- | epan/dissectors/packet-dcm.c | 134 | ||||
-rw-r--r-- | epan/dissectors/packet-http.c | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-ipx.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-iwarp-mpa.c | 25 | ||||
-rw-r--r-- | epan/dissectors/packet-mac-lte.c | 6 | ||||
-rw-r--r-- | epan/dissectors/packet-msrp.c | 11 | ||||
-rw-r--r-- | epan/dissectors/packet-pdcp-lte.c | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-pop.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-rlc-lte.c | 11 | ||||
-rw-r--r-- | epan/dissectors/packet-rtcp.c | 36 | ||||
-rw-r--r-- | epan/dissectors/packet-rtps2.c | 16 | ||||
-rw-r--r-- | epan/dissectors/packet-sip.c | 16 |
14 files changed, 54 insertions, 254 deletions
diff --git a/epan/dissectors/packet-catapult-dct2000.c b/epan/dissectors/packet-catapult-dct2000.c index a7ce5d442a..679af53743 100644 --- a/epan/dissectors/packet-catapult-dct2000.c +++ b/epan/dissectors/packet-catapult-dct2000.c @@ -1197,9 +1197,6 @@ void attach_fp_info(packet_info *pinfo, gboolean received, const char *protocol_ /* Allocate struct */ p_fp_info = se_alloc0(sizeof(struct fp_info)); - if (!p_fp_info) { - return; - } /* Check that the number of outhdr values looks sensible */ if (((strcmp(protocol_name, "fpiur_r5") == 0) && (outhdr_values_found != 2)) || @@ -1367,9 +1364,6 @@ static void attach_mac_lte_info(packet_info *pinfo) /* Allocate & zero struct */ p_mac_lte_info = se_alloc0(sizeof(struct mac_lte_info)); - if (p_mac_lte_info == NULL) { - return; - } /* Populate the struct from outhdr values */ p_mac_lte_info->crcStatusValid = FALSE; @@ -1416,9 +1410,6 @@ static void attach_rlc_lte_info(packet_info *pinfo) /* Allocate & zero struct */ p_rlc_lte_info = se_alloc0(sizeof(struct rlc_lte_info)); - if (p_rlc_lte_info == NULL) { - return; - } p_rlc_lte_info->rlcMode = outhdr_values[i++]; p_rlc_lte_info->direction = outhdr_values[i++]; @@ -1448,9 +1439,6 @@ static void attach_pdcp_lte_info(packet_info *pinfo) /* Allocate & zero struct */ p_pdcp_lte_info = se_alloc0(sizeof(struct pdcp_lte_info)); - if (p_pdcp_lte_info == NULL) { - return; - } p_pdcp_lte_info->no_header_pdu = outhdr_values[i++]; p_pdcp_lte_info->plane = outhdr_values[i++]; @@ -1552,9 +1540,6 @@ static void check_for_oob_mac_lte_events(packet_info *pinfo, tvbuff_t *tvb, prot /* Allocate & zero struct */ p_mac_lte_info = se_alloc0(sizeof(struct mac_lte_info)); - if (p_mac_lte_info == NULL) { - return; - } /* This indicates to MAC dissector that it has an oob event */ p_mac_lte_info->length = 0; diff --git a/epan/dissectors/packet-cip.c b/epan/dissectors/packet-cip.c index 9c2a46d908..04aa7c1d1f 100644 --- a/epan/dissectors/packet-cip.c +++ b/epan/dissectors/packet-cip.c @@ -2718,11 +2718,8 @@ dissect_cip_data( proto_tree *item_tree, tvbuff_t *tvb, int offset, packet_info { /* copy IOI for access by response packet */ preq_info->pIOI = se_alloc( ioilen*2); - if ( preq_info->pIOI ) - { - preq_info->IOILen = ioilen; - tvb_memcpy(tvb, preq_info->pIOI, offset+2, ioilen*2); - } + preq_info->IOILen = ioilen; + tvb_memcpy(tvb, preq_info->pIOI, offset+2, ioilen*2); } } @@ -2765,15 +2762,12 @@ dissect_cip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if ( preq_info == NULL ) { preq_info = se_alloc( sizeof( cip_req_info_t ) ); - if ( preq_info ) - { - preq_info->bService = 0; - preq_info->dissector = NULL; - preq_info->IOILen = 0; - preq_info->pIOI = NULL; - preq_info->pData = NULL; - enip_info->cip_info = preq_info; - } + preq_info->bService = 0; + preq_info->dissector = NULL; + preq_info->IOILen = 0; + preq_info->pIOI = NULL; + preq_info->pData = NULL; + enip_info->cip_info = preq_info; } dissect_cip_data( tree, tvb, 0, pinfo, enip_info->cip_info ); } diff --git a/epan/dissectors/packet-dcm.c b/epan/dissectors/packet-dcm.c index 6b665af128..1f83136c1d 100644 --- a/epan/dissectors/packet-dcm.c +++ b/epan/dissectors/packet-dcm.c @@ -3693,13 +3693,9 @@ dcm_state_new(void) { /* Not much fun. Just create very simple root structure */ - dcm_state_t *ds=NULL; + dcm_state_t *ds; ds = (dcm_state_t *) se_alloc0(sizeof(dcm_state_t)); - if (ds) { - ds->first_assoc=NULL; - ds->last_assoc=NULL; - } return ds; } @@ -3732,9 +3728,7 @@ dcm_state_get(packet_info *pinfo, gboolean create) if (dcm_data == NULL && create) { dcm_data = dcm_state_new(); - if (dcm_data != NULL) { - conversation_add_proto_data(conv, proto_dcm, dcm_data); - } + conversation_add_proto_data(conv, proto_dcm, dcm_data); /* Mark it as DICOM conversation. Needed for the heuristic mode, to prevent stealing subsequent packets by other dissectors @@ -3754,25 +3748,17 @@ dcm_state_assoc_new(dcm_state_t *dcm_data, guint32 packet_no) dcm_state_assoc_t *assoc; assoc = (dcm_state_assoc_t *) se_alloc0(sizeof(dcm_state_assoc_t)); - if (assoc) { - - assoc->next = NULL; - assoc->prev = NULL; - assoc->packet_no = packet_no; /* Identifier */ + assoc->packet_no = packet_no; /* Identifier */ - assoc->first_pctx = NULL; /* List of Presentation context objects */ - assoc->last_pctx = NULL; - - /* add to the end of the list */ - if (dcm_data->last_assoc) { - dcm_data->last_assoc->next = assoc; - assoc->prev = dcm_data->last_assoc; - } - else { - dcm_data->first_assoc = assoc; - } - dcm_data->last_assoc = assoc; + /* add to the end of the list */ + if (dcm_data->last_assoc) { + dcm_data->last_assoc->next = assoc; + assoc->prev = dcm_data->last_assoc; + } + else { + dcm_data->first_assoc = assoc; } + dcm_data->last_assoc = assoc; return assoc; } @@ -3816,32 +3802,18 @@ dcm_state_pctx_new(dcm_state_assoc_t *assoc, guint8 pctx_id) dcm_state_pctx_t *pctx=NULL; pctx = se_alloc0(sizeof(dcm_state_pctx_t)); - if (pctx) { - - pctx->next = NULL; - pctx->prev = NULL; - - pctx->id = pctx_id; - - pctx->abss_uid = NULL; - pctx->abss_desc = NULL; - pctx->xfer_uid = NULL; - pctx->xfer_desc = NULL; - pctx->syntax = DCM_UNK; - - pctx->first_pdv = NULL; /* List of PDV objects */ - pctx->last_pdv = NULL; + pctx->id = pctx_id; + pctx->syntax = DCM_UNK; - /* add to the end of the list list */ - if (assoc->last_pctx) { - assoc->last_pctx->next = pctx; - pctx->prev = assoc->last_pctx; - } - else { - assoc->first_pctx = pctx; - } - assoc->last_pctx = pctx; + /* add to the end of the list list */ + if (assoc->last_pctx) { + assoc->last_pctx->next = pctx; + pctx->prev = assoc->last_pctx; + } + else { + assoc->first_pctx = pctx; } + assoc->last_pctx = pctx; return pctx; } @@ -3880,58 +3852,20 @@ dcm_state_pdv_new(dcm_state_pctx_t *pctx, guint32 packet_no, guint32 offset) dcm_state_pdv_t *pdv = NULL; pdv = (dcm_state_pdv_t *) se_alloc0(sizeof(dcm_state_pdv_t)); - if (pdv != NULL) { - - pdv->prev = NULL; - pdv->next = NULL; - - pdv->data = NULL; - pdv->data_len = 0; - pdv->pctx_id = 0; - pdv->syntax = DCM_UNK; - - pdv->desc = NULL; - - pdv->sop_class_uid = NULL; - pdv->sop_instance_uid = NULL; - - pdv->is_storage = FALSE; - pdv->is_flagvalid = FALSE; - pdv->is_command = FALSE; - pdv->is_last_fragment = TRUE; /* Continuation PDVs are more tricky */ - pdv->is_corrupt = FALSE; - - pdv->packet_no = packet_no; - pdv->offset = offset; - - pdv->status = NULL; - pdv->command = NULL; - pdv->comment = NULL; - pdv->is_warning = FALSE; - - pdv->message_id = 0; - pdv->message_id_resp = 0; - pdv->no_remaining = 0; - pdv->no_completed = 0; - pdv->no_failed = 0; - pdv->no_warning = 0; - - pdv->open_tag.is_header_fragmented = FALSE; - pdv->open_tag.is_value_fragmented = FALSE; - pdv->open_tag.desc = NULL; - pdv->open_tag.len_total = 0; - pdv->open_tag.len_remaining = 0; - - /* add to the end of the list list */ - if (pctx->last_pdv) { - pctx->last_pdv->next = pdv; - pdv->prev = pctx->last_pdv; - } - else { - pctx->first_pdv = pdv; - } - pctx->last_pdv = pdv; + pdv->syntax = DCM_UNK; + pdv->is_last_fragment = TRUE; /* Continuation PDVs are more tricky */ + pdv->packet_no = packet_no; + pdv->offset = offset; + + /* add to the end of the list list */ + if (pctx->last_pdv) { + pctx->last_pdv->next = pdv; + pdv->prev = pctx->last_pdv; + } + else { + pctx->first_pdv = pdv; } + pctx->last_pdv = pdv; return pdv; } diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c index e5401600eb..4e0560a127 100644 --- a/epan/dissectors/packet-http.c +++ b/epan/dissectors/packet-http.c @@ -549,9 +549,6 @@ get_http_conversation_data(packet_info *pinfo) /* Setup the conversation structure itself */ conv_data = se_alloc0(sizeof(http_conv_t)); - conv_data->request_method = NULL; - conv_data->request_uri = NULL; - conversation_add_proto_data(conversation, proto_http, conv_data); } diff --git a/epan/dissectors/packet-ipx.c b/epan/dissectors/packet-ipx.c index 252f9ab73c..ccb3d2f218 100644 --- a/epan/dissectors/packet-ipx.c +++ b/epan/dissectors/packet-ipx.c @@ -502,10 +502,7 @@ spx_hash_insert(conversation_t *conversation, guint32 spx_src, guint16 spx_seq) key->spx_src = spx_src; key->spx_seq = spx_seq; - value = se_alloc(sizeof(spx_hash_value)); - value->spx_ack = 0; - value->spx_all = 0; - value->num = 0; + value = se_alloc0(sizeof(spx_hash_value)); g_hash_table_insert(spx_hash, key, value); diff --git a/epan/dissectors/packet-iwarp-mpa.c b/epan/dissectors/packet-iwarp-mpa.c index 07baaae128..856e1dde98 100644 --- a/epan/dissectors/packet-iwarp-mpa.c +++ b/epan/dissectors/packet-iwarp-mpa.c @@ -208,27 +208,10 @@ typedef struct mpa_state mpa_state_t; static mpa_state_t * init_mpa_state(void) { - mpa_state_t *state= NULL; - guint i; - - state = (mpa_state_t *) se_alloc(sizeof(mpa_state_t)); - - if (state != NULL) { - state->full_operation = FALSE; - state->req_frame_num = 0; - state->rep_frame_num = 0; - state->ini_exp_m_res = FALSE; - state->res_exp_m_ini = FALSE; - for (i=0; i<2; i++) { - state->minfo[i].port = 0; - state->minfo[i].seq = 0; - state->minfo[i].valid = FALSE; - } - state->crc = FALSE; - state->revision = -1; - } else { - THROW(OutOfMemoryError); - } + mpa_state_t *state; + + state = (mpa_state_t *) se_alloc0(sizeof(mpa_state_t)); + state->revision = -1; return state; } diff --git a/epan/dissectors/packet-mac-lte.c b/epan/dissectors/packet-mac-lte.c index 5ae0b61515..bd75a9b71e 100644 --- a/epan/dissectors/packet-mac-lte.c +++ b/epan/dissectors/packet-mac-lte.c @@ -701,9 +701,6 @@ static gboolean dissect_mac_lte_heur(tvbuff_t *tvb, packet_info *pinfo, if (p_mac_lte_info == NULL) { /* Allocate new info struct for this frame */ p_mac_lte_info = se_alloc0(sizeof(struct mac_lte_info)); - if (p_mac_lte_info == NULL) { - return FALSE; - } infoAlreadySet = FALSE; } else { @@ -1179,9 +1176,6 @@ static void call_rlc_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr /* Resuse or create RLC info */ p_rlc_lte_info = p_get_proto_data(pinfo->fd, proto_rlc_lte); - if (p_rlc_lte_info == NULL) { - p_rlc_lte_info = se_alloc0(sizeof(struct rlc_lte_info)); - } /* Fill in struct details for srb channels */ p_rlc_lte_info->rlcMode = mode; diff --git a/epan/dissectors/packet-msrp.c b/epan/dissectors/packet-msrp.c index 3189d88081..b2b0ec0e66 100644 --- a/epan/dissectors/packet-msrp.c +++ b/epan/dissectors/packet-msrp.c @@ -204,12 +204,7 @@ void msrp_add_address( packet_info *pinfo, */ if (!p_conv_data) { /* Create conversation data */ - p_conv_data = se_alloc(sizeof(struct _msrp_conversation_info)); - if (!p_conv_data) - { - return; - } - memset(p_conv_data, 0, sizeof(struct _msrp_conversation_info)); + p_conv_data = se_alloc0(sizeof(struct _msrp_conversation_info)); conversation_add_proto_data(p_conv, proto_msrp, p_conv_data); } @@ -250,10 +245,6 @@ void show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { /* Save this conversation info into packet info */ p_conv_packet_data = se_alloc(sizeof(struct _msrp_conversation_info)); - if (!p_conv_packet_data) - { - return; - } memcpy(p_conv_packet_data, p_conv_data, sizeof(struct _msrp_conversation_info)); diff --git a/epan/dissectors/packet-pdcp-lte.c b/epan/dissectors/packet-pdcp-lte.c index 657bb971af..9e6e48c1f8 100644 --- a/epan/dissectors/packet-pdcp-lte.c +++ b/epan/dissectors/packet-pdcp-lte.c @@ -1396,9 +1396,6 @@ static gboolean dissect_pdcp_lte_heur(tvbuff_t *tvb, packet_info *pinfo, if (p_pdcp_lte_info == NULL) { /* Allocate new info struct for this frame */ p_pdcp_lte_info = se_alloc0(sizeof(struct pdcp_lte_info)); - if (p_pdcp_lte_info == NULL) { - return FALSE; - } infoAlreadySet = FALSE; } else { diff --git a/epan/dissectors/packet-pop.c b/epan/dissectors/packet-pop.c index 5fcd6dc85c..18f1c9a848 100644 --- a/epan/dissectors/packet-pop.c +++ b/epan/dissectors/packet-pop.c @@ -175,10 +175,7 @@ dissect_pop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* * No - create one and attach it. */ - data_val = se_alloc(sizeof(struct pop_data_val)); - data_val->msg_request = FALSE; - data_val->msg_read_len = 0; - data_val->msg_tot_len = 0; + data_val = se_alloc0(sizeof(struct pop_data_val)); conversation_add_proto_data(conversation, proto_pop, data_val); } diff --git a/epan/dissectors/packet-rlc-lte.c b/epan/dissectors/packet-rlc-lte.c index 3f12b9dda5..1184f8aff9 100644 --- a/epan/dissectors/packet-rlc-lte.c +++ b/epan/dissectors/packet-rlc-lte.c @@ -364,9 +364,6 @@ static void show_AM_PDU_in_tree(packet_info *pinfo, proto_tree *tree, tvbuff_t * if (p_pdcp_lte_info == NULL) { p_pdcp_lte_info = se_alloc0(sizeof(struct pdcp_lte_info)); } - if (p_pdcp_lte_info == NULL) { - return; - } p_pdcp_lte_info->channelType = Channel_DCCH; p_pdcp_lte_info->direction = rlc_info->direction; @@ -604,11 +601,6 @@ static void checkChannelSequenceInfo(packet_info *pinfo, tvbuff_t *tvb, p_channel_key = se_alloc(sizeof(rlc_channel_hash_key)); p_channel_status = se_alloc0(sizeof(rlc_channel_status)); - /* Just give up if allocations failed */ - if (!p_channel_key || !p_channel_status) { - return; - } - /* Copy key contents */ memcpy(p_channel_key, &channel_key, sizeof(rlc_channel_hash_key)); @@ -1201,9 +1193,6 @@ static gboolean dissect_rlc_lte_heur(tvbuff_t *tvb, packet_info *pinfo, if (p_rlc_lte_info == NULL) { /* Allocate new info struct for this frame */ p_rlc_lte_info = se_alloc0(sizeof(struct rlc_lte_info)); - if (p_rlc_lte_info == NULL) { - return FALSE; - } infoAlreadySet = FALSE; } else { diff --git a/epan/dissectors/packet-rtcp.c b/epan/dissectors/packet-rtcp.c index 39f293986e..ac150f726d 100644 --- a/epan/dissectors/packet-rtcp.c +++ b/epan/dissectors/packet-rtcp.c @@ -569,12 +569,7 @@ void srtcp_add_address( packet_info *pinfo, */ if ( ! p_conv_data ) { /* Create conversation data */ - p_conv_data = se_alloc(sizeof(struct _rtcp_conversation_info)); - if (!p_conv_data) - { - return; - } - memset(p_conv_data, 0, sizeof(struct _rtcp_conversation_info)); + p_conv_data = se_alloc0(sizeof(struct _rtcp_conversation_info)); conversation_add_proto_data(p_conv, proto_rtcp, p_conv_data); } @@ -2199,10 +2194,6 @@ void show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { /* Save this conversation info into packet info */ p_conv_packet_data = se_alloc(sizeof(struct _rtcp_conversation_info)); - if (!p_conv_packet_data) - { - return; - } memcpy(p_conv_packet_data, p_conv_data, sizeof(struct _rtcp_conversation_info)); @@ -2292,13 +2283,7 @@ static void remember_outgoing_sr(packet_info *pinfo, long lsr) if (!p_conv_data) { /* Allocate memory for data */ - p_conv_data = se_alloc(sizeof(struct _rtcp_conversation_info)); - if (!p_conv_data) - { - /* Give up if couldn't allocate space for memory */ - return; - } - memset(p_conv_data, 0, sizeof(struct _rtcp_conversation_info)); + p_conv_data = se_alloc0(sizeof(struct _rtcp_conversation_info)); /* Add it to conversation. */ conversation_add_proto_data(p_conv, proto_rtcp, p_conv_data); @@ -2318,13 +2303,7 @@ static void remember_outgoing_sr(packet_info *pinfo, long lsr) /* Will use/create packet info */ if (!p_packet_data) { - p_packet_data = se_alloc(sizeof(struct _rtcp_conversation_info)); - if (!p_packet_data) - { - /* Give up if allocation fails */ - return; - } - memset(p_packet_data, 0, sizeof(struct _rtcp_conversation_info)); + p_packet_data = se_alloc0(sizeof(struct _rtcp_conversation_info)); p_add_proto_data(pinfo->fd, proto_rtcp, p_packet_data); } @@ -2393,14 +2372,7 @@ static void calculate_roundtrip_delay(tvbuff_t *tvb, packet_info *pinfo, if (!p_packet_data) { /* Create packet info if it doesn't exist */ - p_packet_data = se_alloc(sizeof(struct _rtcp_conversation_info)); - if (!p_packet_data) - { - /* Give up if allocation fails */ - return; - } - - memset(p_packet_data, 0, sizeof(struct _rtcp_conversation_info)); + p_packet_data = se_alloc0(sizeof(struct _rtcp_conversation_info)); /* Set as packet info */ p_add_proto_data(pinfo->fd, proto_rtcp, p_packet_data); diff --git a/epan/dissectors/packet-rtps2.c b/epan/dissectors/packet-rtps2.c index f7dd5a0892..2b52004f3c 100644 --- a/epan/dissectors/packet-rtps2.c +++ b/epan/dissectors/packet-rtps2.c @@ -8248,23 +8248,7 @@ static void dissect_RTPS_DATA_BATCH(tvbuff_t *tvb, sample_info_max = 1024; /* Max size of sampleInfo shown */ } sample_info_flags = (guint16 *)ep_alloc(sizeof(guint16) * sample_info_max); - if (sample_info_flags == NULL) { - proto_tree_add_text(tree, - tvb, - offset, - 2, - "out of memory allocating sample_info_flags"); - return; - } sample_info_length = (guint32 *)ep_alloc(sizeof(guint32) * sample_info_max); - if (sample_info_length == NULL) { - proto_tree_add_text(tree, - tvb, - offset, - 2, - "out of memory allocating sample_info_length"); - return; - } /* Sample Info List: start decoding the sample info list until the offset * is greater or equal than 'sampleListOffset' */ diff --git a/epan/dissectors/packet-sip.c b/epan/dissectors/packet-sip.c index 26fe61e4b2..0509d5add1 100644 --- a/epan/dissectors/packet-sip.c +++ b/epan/dissectors/packet-sip.c @@ -1895,15 +1895,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tr } /* Initialise stat info for passing to tap */ - stat_info = ep_alloc(sizeof(sip_info_value_t)); - stat_info->response_code = 0; - stat_info->request_method = NULL; - stat_info->reason_phrase = NULL; - stat_info->resend = 0; - stat_info->setup_time = 0; - stat_info->tap_call_id = NULL; - stat_info->tap_from_addr = NULL; - stat_info->tap_to_addr = NULL; + stat_info = ep_alloc0(sizeof(sip_info_value_t)); col_set_str(pinfo->cinfo, COL_PROTOCOL, "SIP"); @@ -3412,12 +3404,6 @@ guint sip_is_packet_resend(packet_info *pinfo, p_key = se_alloc(sizeof(sip_hash_key)); p_val = se_alloc(sizeof(sip_hash_value)); - /* Just give up if allocations failed */ - if (!p_key || !p_val) - { - return 0; - } - /* Fill in key and value details */ g_snprintf(p_key->call_id, MAX_CALL_ID_SIZE, "%s", call_id); SE_COPY_ADDRESS(&(p_key->dest_address), &pinfo->net_dst); |