Grab-bag of dead initializers and two actual bugs.

All caught by cppcheck. The two (semi)-interesting bugs are:
- in asn1/atn-cpdlc/packet-atn-cpdlc-template.c where the break statement should
  have been inside the brace, causing potential control-flow weirdness with
  exceptions
- in epan/dissectors/packet-ieee80211.c where the bounds check for tag_len did
  not match the expert info given

Change-Id: Ie173fb8d917aabb9b4571435d671d6f16e1c7569
Reviewed-on: https://code.wireshark.org/review/1793
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Evan Huus <eapache@gmail.com>
This commit is contained in:
Evan Huus 2014-05-25 11:13:04 -04:00
parent c4ead251da
commit 08ce84ebbe
14 changed files with 35 additions and 38 deletions

View File

@ -74,9 +74,9 @@ dissect_atn_cm(
proto_tree *tree,
void *data _U_)
{
int type = no_msg;
proto_item *ti = NULL;
proto_tree *sub_tree = NULL;
int type;
proto_item *ti;
proto_tree *sub_tree;
ti = proto_tree_add_text(
tree,

View File

@ -218,7 +218,7 @@ dissect_atn_cpdlc_heur(
atn_conversation_t *atn_cv = NULL;
volatile gboolean is_atn_cpdlc = FALSE;
volatile gboolean is_pm = FALSE;
int type = no_msg;
int type;
type = check_heur_msg_type(pinfo);
@ -227,8 +227,8 @@ dissect_atn_cpdlc_heur(
TRY {
dissect_ProtectedGroundPDUs_PDU(tvb, pinfo, NULL);
is_atn_cpdlc = TRUE;
is_pm = TRUE;}
break;
is_pm = TRUE;
break;}
CATCH_ALL{
is_atn_cpdlc = FALSE;
is_pm = FALSE;}

View File

@ -7005,15 +7005,13 @@ static void dissect_asterix_packet (tvbuff_t *tvb, proto_tree *tree)
guint i;
guint8 category;
guint16 length;
proto_item *asterix_packet_item = NULL;
proto_tree *asterix_packet_tree = NULL;
proto_item *asterix_packet_item;
proto_tree *asterix_packet_tree;
for (i = 0; i < tvb_reported_length (tvb); i += length + 3) {
category = tvb_get_guint8 (tvb, i);
length = (tvb_get_guint8 (tvb, i + 1) << 8) + tvb_get_guint8 (tvb, i + 2) - 3; /* -3 for category and length */
asterix_packet_item = NULL;
asterix_packet_tree = NULL;
asterix_packet_item = proto_tree_add_item (tree, proto_asterix, tvb, i, length + 3, ENC_NA);
proto_item_append_text (asterix_packet_item, ", Category %03d", category);
asterix_packet_tree = proto_item_add_subtree (asterix_packet_item, ett_asterix);
@ -7117,7 +7115,6 @@ static void asterix_build_subtree (tvbuff_t *tvb, guint offset, proto_tree *pare
if (field->part != NULL) {
for (i = 0, inner_offset = 0, go_on = 1; go_on && field->part[i] != NULL; i++) {
value = G_GINT64_CONSTANT(0);;
value = tvb_get_bits64 (tvb, offset * 8 + inner_offset, field->part[i]->bit_length, ENC_BIG_ENDIAN);
if (field->part[i]->hf != NULL) {
switch (field->part[i]->type) {

View File

@ -641,9 +641,9 @@ dissect_atn_cm(
proto_tree *tree,
void *data _U_)
{
int type = no_msg;
proto_item *ti = NULL;
proto_tree *sub_tree = NULL;
int type;
proto_item *ti;
proto_tree *sub_tree;
ti = proto_tree_add_text(
tree,

View File

@ -5415,7 +5415,7 @@ dissect_atn_cpdlc_heur(
atn_conversation_t *atn_cv = NULL;
volatile gboolean is_atn_cpdlc = FALSE;
volatile gboolean is_pm = FALSE;
int type = no_msg;
int type;
type = check_heur_msg_type(pinfo);
@ -5424,8 +5424,8 @@ dissect_atn_cpdlc_heur(
TRY {
dissect_ProtectedGroundPDUs_PDU(tvb, pinfo, NULL);
is_atn_cpdlc = TRUE;
is_pm = TRUE;}
break;
is_pm = TRUE;
break;}
CATCH_ALL{
is_atn_cpdlc = FALSE;
is_pm = FALSE;}

View File

@ -2238,7 +2238,7 @@ static void dissect_batadv_unicast_frag_v12(tvbuff_t *tvb, packet_info *pinfo, p
proto_item *tf;
struct unicast_frag_packet_v12 *unicast_frag_packeth;
const guint8 *dest_addr, *orig_addr;
gboolean save_fragmented = FALSE;
gboolean save_fragmented;
fragment_head *frag_msg = NULL;
proto_tree *batadv_unicast_frag_tree = NULL, *flag_tree;
@ -2344,7 +2344,7 @@ static void dissect_batadv_unicast_frag_v14(tvbuff_t *tvb, packet_info *pinfo, p
proto_item *tf;
struct unicast_frag_packet_v14 *unicast_frag_packeth;
const guint8 *dest_addr, *orig_addr;
gboolean save_fragmented = FALSE;
gboolean save_fragmented;
fragment_head *frag_msg = NULL;
proto_tree *batadv_unicast_frag_tree = NULL, *flag_tree;

View File

@ -2502,7 +2502,6 @@ netlogon_dissect_netrserverreqchallenge_rqst(tvbuff_t *tvb, int offset,
vars->next = NULL;
generate_hash_key(pinfo,0,key,NULL);
existing_vars = NULL;
existing_vars = (netlogon_auth_vars *)g_hash_table_lookup(netlogon_auths, key);
if (!existing_vars) {
debugprintf("Adding initial vars with this start packet = %d\n",vars->start);

View File

@ -82,7 +82,7 @@ dissect_ndr_datablob(tvbuff_t *tvb, int offset, packet_info *pinfo,
{
proto_item *item;
guint3264 len;
proto_tree *subtree = tree;
proto_tree *subtree;
item = proto_tree_add_text(tree, tvb, offset, 0, "%s",
proto_registrar_get_name(hf_index));

View File

@ -339,7 +339,7 @@ dissect_pft_fec_detailed(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree,
}
}
if(new_tvb && tvb_length(new_tvb) > 0) {
gboolean decoded = TRUE;
gboolean decoded;
tvbuff_t *dtvb = NULL;
const guint8 *input = tvb_get_ptr(new_tvb, 0, -1);
guint32 reassembled_size = tvb_length(new_tvb);

View File

@ -10757,7 +10757,7 @@ dissect_vht_tx_pwr_envelope(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint8 opt_ie_cnt=0;
guint8 i;
if (tag_len < 2 && tag_len <= 5) {
if (tag_len < 2 || tag_len > 5) {
expert_add_info_format(pinfo, ti_len, &ei_ieee80211_tag_length,
"VHT TX PWR Envelope IE length %u wrong, must be >= 2 and <= 5", tag_len);
return offset;
@ -11434,7 +11434,7 @@ dissect_wapi_param_set(tvbuff_t *tvb, packet_info *pinfo,
/* Parse the WAPI Parameter Set IE Here*/
proto_item *item;
proto_tree *subtree;
guint16 loop_cnt, version = 1, akm_cnt = 1, ucast_cnt = 1, bkid_cnt = 1;
guint16 loop_cnt, version, akm_cnt = 1, ucast_cnt = 1, bkid_cnt = 1;
guint8 akm_suite_type = 0, ucast_cipher_type = 0, mcast_cipher_type = 0;
version = tvb_get_letohs(tvb, offset);

View File

@ -2101,11 +2101,11 @@ dissect_lisp_map_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tre
guint16 addr_len = 0;
gint offset = 0;
guint16 flags;
gboolean mrep = FALSE;
gboolean smr = FALSE;
gboolean probe = FALSE;
gboolean pitr = FALSE;
gboolean smr_invoked = FALSE;
gboolean mrep;
gboolean smr;
gboolean probe;
gboolean pitr;
gboolean smr_invoked;
guint8 itr_rec_cnt = 0;
guint8 rec_cnt = 0;
guint16 src_eid_afi;
@ -2350,7 +2350,7 @@ dissect_lisp_map_reply(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tree)
{
int i;
gint offset = 0;
gboolean probe = FALSE;
gboolean probe;
guint8 flags;
guint8 rec_cnt = 0;
tvbuff_t *next_tvb;
@ -2437,8 +2437,8 @@ dissect_lisp_map_register(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tr
tvbuff_t *next_tvb;
guint16 authlen = 0;
guint16 flags;
gboolean xtrid = FALSE;
gboolean rtr = FALSE;
gboolean xtrid;
gboolean rtr;
/* Flags (1 bit) */
proto_tree_add_item(lisp_tree, hf_lisp_mreg_flags_pmr, tvb, offset, 3, ENC_BIG_ENDIAN);
@ -2550,8 +2550,8 @@ dissect_lisp_map_notify(tvbuff_t *tvb, packet_info *pinfo, proto_tree *lisp_tree
tvbuff_t *next_tvb;
guint16 authlen = 0;
guint16 flags;
gboolean xtrid = FALSE;
gboolean rtr = FALSE;
gboolean xtrid;
gboolean rtr;
/* Flags defined in NAT Traversal draft (2 bits) */
flags = tvb_get_ntohs(tvb, offset);

View File

@ -1389,9 +1389,7 @@ static guint mac_lte_framenum_instance_hash_func(gconstpointer v)
{
const drx_state_key_t *p1 = (const drx_state_key_t*)v;
/* XXX which one return ? */
return p1->frameNumber + (p1->pdu_instance >> 8);
return GPOINTER_TO_UINT(v);
}
@ -4275,6 +4273,10 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
curr_offset++;
}
} else {
/* XXX dead code? Expression is always false because
* the condition matches previous condition in the
* original if (so if it were true we'd never get
* to this 'else' block in the first place) */
if ((gint16)(computed_header_offset + 1 - curr_offset) != pdu_lengths[n]) {
expert_add_info_format(pinfo, ephr_ti, &ei_mac_lte_control_element_size_invalid,
"Control Element has an unexpected size (computed=%d, actual=%d)",

View File

@ -291,7 +291,7 @@ dissect_bson_document(tvbuff_t *tvb, packet_info *pinfo, guint offset, proto_tre
do {
/* Read document elements */
guint8 e_type = -1; /* Element type */
guint8 e_type; /* Element type */
gint str_len = -1; /* String length */
gint e_len = -1; /* Element length */
gint doc_len = -1; /* Document length */

View File

@ -2513,7 +2513,6 @@ dissect_openflow_port_desc_prop_ethernet_v5(tvbuff_t *tvb, packet_info *pinfo _U
offset+=4;
return offset;
return offset;
}