diff options
author | Bill Meier <wmeier@newsguy.com> | 2012-06-12 21:22:46 +0000 |
---|---|---|
committer | Bill Meier <wmeier@newsguy.com> | 2012-06-12 21:22:46 +0000 |
commit | 1b17369504e600fbddc53c67d634039ba37ac6b7 (patch) | |
tree | 3bf66240055157786e65245a2966939bf0d571c7 /epan/dissectors | |
parent | 5b53b81835a64b5219236922c7c91e7d9c3c1efb (diff) |
Fix: code under 'if(tree)' (in)directly calls sub-dissector/col_...()/expert...() fcns
svn path=/trunk/; revision=43226
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/packet-bacapp.c | 65 | ||||
-rw-r--r-- | epan/dissectors/packet-banana.c | 20 | ||||
-rw-r--r-- | epan/dissectors/packet-bfcp.c | 111 | ||||
-rw-r--r-- | epan/dissectors/packet-bgp.c | 75 | ||||
-rw-r--r-- | epan/dissectors/packet-cell_broadcast.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-cip.c | 33 | ||||
-rw-r--r-- | epan/dissectors/packet-cipsafety.c | 36 | ||||
-rw-r--r-- | epan/dissectors/packet-dmx.c | 69 | ||||
-rw-r--r-- | epan/dissectors/packet-dvb-data-mpe.c | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-llrp.c | 41 | ||||
-rw-r--r-- | epan/dissectors/packet-moldudp.c | 63 | ||||
-rw-r--r-- | epan/dissectors/packet-moldudp64.c | 61 | ||||
-rw-r--r-- | epan/dissectors/packet-mpeg-pat.c | 3 | ||||
-rw-r--r-- | epan/dissectors/packet-mpeg-sect.c | 18 | ||||
-rw-r--r-- | epan/dissectors/packet-openwire.c | 59 |
15 files changed, 310 insertions, 349 deletions
diff --git a/epan/dissectors/packet-bacapp.c b/epan/dissectors/packet-bacapp.c index a3281b41bc..2ceec52b28 100644 --- a/epan/dissectors/packet-bacapp.c +++ b/epan/dissectors/packet-bacapp.c @@ -4868,13 +4868,12 @@ static guint fTagHeaderTree (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, guint8 *tag_no, guint8* tag_info, guint32 *lvt) { + proto_item *ti = NULL; guint8 tag; guint8 value; guint tag_len = 1; guint lvt_len = 1; /* used for tree display of lvt */ guint lvt_offset; /* used for tree display of lvt */ - proto_item *ti; - proto_tree *subtree; lvt_offset = offset; tag = tvb_get_guint8(tvb, offset); @@ -4906,67 +4905,65 @@ fTagHeaderTree (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } if (tree) { + proto_tree *subtree; if (tag_is_opening(tag)) ti = proto_tree_add_text(tree, tvb, offset, tag_len, "{[%u]", *tag_no ); else if (tag_is_closing(tag)) ti = proto_tree_add_text(tree, tvb, offset, tag_len, "}[%u]", *tag_no ); else if (tag_is_context_specific(tag)) { ti = proto_tree_add_text(tree, tvb, offset, tag_len, - "Context Tag: %u, Length/Value/Type: %u", - *tag_no, *lvt); + "Context Tag: %u, Length/Value/Type: %u", + *tag_no, *lvt); } else ti = proto_tree_add_text(tree, tvb, offset, tag_len, - "Application Tag: %s, Length/Value/Type: %u", - val_to_str(*tag_no, - BACnetApplicationTagNumber, - ASHRAE_Reserved_Fmt), - *lvt); + "Application Tag: %s, Length/Value/Type: %u", + val_to_str(*tag_no, + BACnetApplicationTagNumber, + ASHRAE_Reserved_Fmt), + *lvt); - subtree = proto_item_add_subtree(ti, ett_bacapp_tag); /* details if needed */ + subtree = proto_item_add_subtree(ti, ett_bacapp_tag); proto_tree_add_item(subtree, hf_BACnetTagClass, tvb, offset, 1, ENC_BIG_ENDIAN); if (tag_is_extended_tag_number(tag)) { proto_tree_add_uint_format(subtree, - hf_BACnetContextTagNumber, - tvb, offset, 1, tag, - "Extended Tag Number"); + hf_BACnetContextTagNumber, + tvb, offset, 1, tag, + "Extended Tag Number"); proto_tree_add_item(subtree, - hf_BACnetExtendedTagNumber, - tvb, offset + 1, 1, ENC_BIG_ENDIAN); + hf_BACnetExtendedTagNumber, + tvb, offset + 1, 1, ENC_BIG_ENDIAN); } else { if (tag_is_context_specific(tag)) proto_tree_add_item(subtree, - hf_BACnetContextTagNumber, - tvb, offset, 1, ENC_BIG_ENDIAN); + hf_BACnetContextTagNumber, + tvb, offset, 1, ENC_BIG_ENDIAN); else proto_tree_add_item(subtree, - hf_BACnetApplicationTagNumber, - tvb, offset, 1, ENC_BIG_ENDIAN); + hf_BACnetApplicationTagNumber, + tvb, offset, 1, ENC_BIG_ENDIAN); } if (tag_is_closing(tag) || tag_is_opening(tag)) proto_tree_add_item(subtree, - hf_BACnetNamedTag, - tvb, offset, 1, ENC_BIG_ENDIAN); + hf_BACnetNamedTag, + tvb, offset, 1, ENC_BIG_ENDIAN); else if (tag_is_extended_value(tag)) { proto_tree_add_item(subtree, - hf_BACnetNamedTag, - tvb, offset, 1, ENC_BIG_ENDIAN); + hf_BACnetNamedTag, + tvb, offset, 1, ENC_BIG_ENDIAN); proto_tree_add_uint(subtree, hf_bacapp_tag_lvt, - tvb, lvt_offset, lvt_len, *lvt); + tvb, lvt_offset, lvt_len, *lvt); } else proto_tree_add_uint(subtree, hf_bacapp_tag_lvt, - tvb, lvt_offset, lvt_len, *lvt); + tvb, lvt_offset, lvt_len, *lvt); + } /* if (tree) */ - if (*lvt > tvb_length(tvb)) { - expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR, - "LVT length too long: %d > %d", *lvt, - tvb_length(tvb)); - *lvt = 1; - } - } - else if (*lvt > tvb_length(tvb)) - /* We can't add expert info, but we can still stop infinite loops */ + if (*lvt > tvb_length(tvb)) { + expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR, + "LVT length too long: %d > %d", *lvt, + tvb_length(tvb)); *lvt = 1; + } return tag_len; } diff --git a/epan/dissectors/packet-banana.c b/epan/dissectors/packet-banana.c index c7bbfdbc3b..52691be418 100644 --- a/epan/dissectors/packet-banana.c +++ b/epan/dissectors/packet-banana.c @@ -238,17 +238,15 @@ dissect_banana(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { col_add_fstr(pinfo->cinfo, COL_INFO, "First element: %s", val_to_str(byte, type_vals, "Unknown type: %u")); - if (tree) { - /* Create display subtree for the protocol */ - ti = proto_tree_add_item(tree, proto_banana, tvb, 0, -1, ENC_NA); - banana_tree = proto_item_add_subtree(ti, ett_banana); - - offset = 0; - old_offset = -1; - while (offset > old_offset) { - old_offset = offset; - offset += dissect_banana_element(tvb, pinfo, banana_tree, offset); - } + /* Create display subtree for the protocol */ + ti = proto_tree_add_item(tree, proto_banana, tvb, 0, -1, ENC_NA); + banana_tree = proto_item_add_subtree(ti, ett_banana); + + offset = 0; + old_offset = -1; + while (offset > old_offset) { + old_offset = offset; + offset += dissect_banana_element(tvb, pinfo, banana_tree, offset); } /* Return the amount of data this dissector was able to dissect */ diff --git a/epan/dissectors/packet-bfcp.c b/epan/dissectors/packet-bfcp.c index e256254fff..16886ec0c0 100644 --- a/epan/dissectors/packet-bfcp.c +++ b/epan/dissectors/packet-bfcp.c @@ -129,6 +129,9 @@ static gboolean dissect_bfcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree guint8 primitive; const gchar *str; gint bfcp_payload_length; + gint read_attr = 0; + proto_tree *bfcp_tree = NULL; + /* Size of smallest BFCP packet: 12 octets */ if (tvb_length(tvb) < 12) @@ -158,77 +161,75 @@ static gboolean dissect_bfcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree col_add_str(pinfo->cinfo, COL_INFO, str); if (tree) { - gint read_attr = 0; - proto_item *ti; - proto_tree *bfcp_tree; - + proto_item *ti; ti = proto_tree_add_item(tree, proto_bfcp, tvb, 0, -1, ENC_NA); bfcp_tree = proto_item_add_subtree(ti, ett_bfcp); /* Add items to BFCP tree */ proto_tree_add_item(bfcp_tree, hf_bfcp_transaction_initiator, tvb, - BFCP_OFFSET_TRANSACTION_INITIATOR, 1, ENC_BIG_ENDIAN); + BFCP_OFFSET_TRANSACTION_INITIATOR, 1, ENC_BIG_ENDIAN); proto_tree_add_item(bfcp_tree, hf_bfcp_primitive, tvb, - BFCP_OFFSET_PRIMITIVE, 1, ENC_BIG_ENDIAN); + BFCP_OFFSET_PRIMITIVE, 1, ENC_BIG_ENDIAN); proto_tree_add_item(bfcp_tree, hf_bfcp_payload_length, tvb, - BFCP_OFFSET_PAYLOAD_LENGTH, 2, ENC_BIG_ENDIAN); + BFCP_OFFSET_PAYLOAD_LENGTH, 2, ENC_BIG_ENDIAN); proto_tree_add_item(bfcp_tree, hf_bfcp_conference_id, tvb, - BFCP_OFFSET_CONFERENCE_ID, 4, ENC_BIG_ENDIAN); + BFCP_OFFSET_CONFERENCE_ID, 4, ENC_BIG_ENDIAN); proto_tree_add_item(bfcp_tree, hf_bfcp_transaction_id, tvb, - BFCP_OFFSET_TRANSACTION_ID, 2, ENC_BIG_ENDIAN); + BFCP_OFFSET_TRANSACTION_ID, 2, ENC_BIG_ENDIAN); proto_tree_add_item(bfcp_tree, hf_bfcp_user_id, tvb, - BFCP_OFFSET_USER_ID, 2, ENC_BIG_ENDIAN); + BFCP_OFFSET_USER_ID, 2, ENC_BIG_ENDIAN); + } - bfcp_payload_length = tvb_get_ntohs(tvb, - BFCP_OFFSET_PAYLOAD_LENGTH) * 4; + bfcp_payload_length = tvb_get_ntohs(tvb, + BFCP_OFFSET_PAYLOAD_LENGTH) * 4; - while ((tvb_reported_length_remaining(tvb, BFCP_OFFSET_PAYLOAD + read_attr) >= 2) && - ((bfcp_payload_length - read_attr) >= 2)) + while ((tvb_reported_length_remaining(tvb, BFCP_OFFSET_PAYLOAD + read_attr) >= 2) && + ((bfcp_payload_length - read_attr) >= 2)) + { + proto_item *ti; + gint read = 0; + gint length; + guint8 first_byte; + guint8 attribute_type; + + first_byte = tvb_get_guint8(tvb, BFCP_OFFSET_PAYLOAD + read_attr); + + /* Padding so continue to next attribute */ + if (first_byte == 0) { - gint read = 0; - gint length; - guint8 first_byte; - guint8 attribute_type; - - first_byte = tvb_get_guint8(tvb, BFCP_OFFSET_PAYLOAD + read_attr); - - /* Padding so continue to next attribute */ - if (first_byte == 0) - { - read_attr++; - continue; - } - - proto_tree_add_item(bfcp_tree, hf_bfcp_attribute_types, tvb, - BFCP_OFFSET_PAYLOAD + read_attr,1, ENC_BIG_ENDIAN); - attribute_type = (first_byte & 0xFE) >> 1; - read++; + read_attr++; + continue; + } - ti = proto_tree_add_item(bfcp_tree, hf_bfcp_attribute_length, tvb, - BFCP_OFFSET_PAYLOAD + read_attr + read,1, ENC_BIG_ENDIAN); - length = tvb_get_guint8(tvb, BFCP_OFFSET_PAYLOAD + read_attr + read); - read++; + proto_tree_add_item(bfcp_tree, hf_bfcp_attribute_types, tvb, + BFCP_OFFSET_PAYLOAD + read_attr,1, ENC_BIG_ENDIAN); + attribute_type = (first_byte & 0xFE) >> 1; + read++; + + ti = proto_tree_add_item(bfcp_tree, hf_bfcp_attribute_length, tvb, + BFCP_OFFSET_PAYLOAD + read_attr + read,1, ENC_BIG_ENDIAN); + length = tvb_get_guint8(tvb, BFCP_OFFSET_PAYLOAD + read_attr + read); + read++; - /* If RequestStatus then show what type of status it is... */ - if (attribute_type == 5) - { - proto_tree_add_item(bfcp_tree, hf_bfcp_request_status, tvb, - BFCP_OFFSET_PAYLOAD + read_attr + read,1, ENC_BIG_ENDIAN); - read++; - } - if (length >= read) - { - proto_tree_add_item(bfcp_tree, hf_bfcp_payload, tvb, - BFCP_OFFSET_PAYLOAD + read_attr + read, length-read, ENC_NA); - } - else - { - expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR, - "Attribute length is too small (%d bytes)", length); - break; - } - read_attr = read_attr + length; + /* If RequestStatus then show what type of status it is... */ + if (attribute_type == 5) + { + proto_tree_add_item(bfcp_tree, hf_bfcp_request_status, tvb, + BFCP_OFFSET_PAYLOAD + read_attr + read,1, ENC_BIG_ENDIAN); + read++; + } + if (length >= read) + { + proto_tree_add_item(bfcp_tree, hf_bfcp_payload, tvb, + BFCP_OFFSET_PAYLOAD + read_attr + read, length-read, ENC_NA); + } + else + { + expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR, + "Attribute length is too small (%d bytes)", length); + break; } + read_attr = read_attr + length; } return TRUE; } diff --git a/epan/dissectors/packet-bgp.c b/epan/dissectors/packet-bgp.c index c59831f147..1f76790468 100644 --- a/epan/dissectors/packet-bgp.c +++ b/epan/dissectors/packet-bgp.c @@ -2366,6 +2366,9 @@ dissect_bgp_update(tvbuff_t *tvb, proto_tree *tree) guint8 encaps_tunnel_subtype; /* Encapsulation Tunnel Sub-TLV Type */ guint8 encaps_tunnel_sublen; /* Encapsulation TLV Sub-TLV Length */ + if (!tree) + return; + hlen = tvb_get_ntohs(tvb, BGP_MARKER_SIZE); o = BGP_HEADER_SIZE; junk_emstr = ep_strbuf_new_label(NULL); @@ -3602,6 +3605,9 @@ example 2 18 le = 24 10 07 02 prefix = 7.2.0.0/16 */ + if (!tree) + return; + hlen = tvb_get_ntohs(tvb, BGP_MARKER_SIZE); p = BGP_HEADER_SIZE; /* AFI */ @@ -3709,12 +3715,11 @@ static void dissect_bgp_pdu(tvbuff_t *volatile tvb, packet_info *pinfo, proto_tree *tree, gboolean first) { - guint16 bgp_len; /* Message length */ - guint8 bgp_type; /* Message type */ - const char *typ; /* Message type (string) */ - proto_item *ti; /* tree item */ - proto_item *ti_len; /* length item */ - proto_tree *bgp_tree; /* BGP packet tree */ + guint16 bgp_len; /* Message length */ + guint8 bgp_type; /* Message type */ + const char *typ; /* Message type (string) */ + proto_item *ti_len = NULL; /* length item */ + proto_tree *bgp_tree = NULL; /* BGP packet tree */ bgp_len = tvb_get_ntohs(tvb, BGP_MARKER_SIZE); bgp_type = tvb_get_guint8(tvb, BGP_MARKER_SIZE + 2); @@ -3726,6 +3731,7 @@ dissect_bgp_pdu(tvbuff_t *volatile tvb, packet_info *pinfo, proto_tree *tree, col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", typ); if (tree) { + proto_item *ti; ti = proto_tree_add_item(tree, proto_bgp, tvb, 0, -1, ENC_NA); proto_item_append_text(ti, " - %s", typ); @@ -3758,36 +3764,37 @@ dissect_bgp_pdu(tvbuff_t *volatile tvb, packet_info *pinfo, proto_tree *tree, proto_tree_add_item(bgp_tree, hf_bgp_marker, tvb, 0, 16, ENC_NA); ti_len = proto_tree_add_item(bgp_tree, hf_bgp_length, tvb, 16, 2, ENC_BIG_ENDIAN); - if (bgp_len < BGP_HEADER_SIZE || bgp_len > BGP_MAX_PACKET_SIZE) { - expert_add_info_format(pinfo, ti_len, PI_MALFORMED, PI_ERROR, "Length is invalid %u", bgp_len); - return; - } + } - proto_tree_add_item(bgp_tree, hf_bgp_type, tvb, 16 + 2, 1, ENC_BIG_ENDIAN); + if (bgp_len < BGP_HEADER_SIZE || bgp_len > BGP_MAX_PACKET_SIZE) { + expert_add_info_format(pinfo, ti_len, PI_MALFORMED, PI_ERROR, "Length is invalid %u", bgp_len); + return; + } - switch (bgp_type) { - case BGP_OPEN: - dissect_bgp_open(tvb, bgp_tree, pinfo); - break; - case BGP_UPDATE: - dissect_bgp_update(tvb, bgp_tree); - break; - case BGP_NOTIFICATION: - dissect_bgp_notification(tvb, bgp_tree, pinfo); - break; - case BGP_KEEPALIVE: - /* no data in KEEPALIVE messages */ - break; - case BGP_ROUTE_REFRESH_CISCO: - case BGP_ROUTE_REFRESH: - dissect_bgp_route_refresh(tvb, bgp_tree); - break; - case BGP_CAPABILITY: - dissect_bgp_capability(tvb, bgp_tree, pinfo); - break; - default: - break; - } + proto_tree_add_item(bgp_tree, hf_bgp_type, tvb, 16 + 2, 1, ENC_BIG_ENDIAN); + + switch (bgp_type) { + case BGP_OPEN: + dissect_bgp_open(tvb, bgp_tree, pinfo); + break; + case BGP_UPDATE: + dissect_bgp_update(tvb, bgp_tree); + break; + case BGP_NOTIFICATION: + dissect_bgp_notification(tvb, bgp_tree, pinfo); + break; + case BGP_KEEPALIVE: + /* no data in KEEPALIVE messages */ + break; + case BGP_ROUTE_REFRESH_CISCO: + case BGP_ROUTE_REFRESH: + dissect_bgp_route_refresh(tvb, bgp_tree); + break; + case BGP_CAPABILITY: + dissect_bgp_capability(tvb, bgp_tree, pinfo); + break; + default: + break; } } diff --git a/epan/dissectors/packet-cell_broadcast.c b/epan/dissectors/packet-cell_broadcast.c index ad62ea7418..2ebe4e143c 100644 --- a/epan/dissectors/packet-cell_broadcast.c +++ b/epan/dissectors/packet-cell_broadcast.c @@ -364,7 +364,7 @@ dissect_gsm_cell_broadcast(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) frag_data, &gsm_page_items, NULL, cbs_page_tree); } } - if ((tree != NULL) && (cbs_msg_tvb != NULL)) + if (cbs_msg_tvb != NULL) { guint16 len; proto_item *cbs_msg_item = NULL; diff --git a/epan/dissectors/packet-cip.c b/epan/dissectors/packet-cip.c index 5c70ec3d6a..f2ccb4a2d8 100644 --- a/epan/dissectors/packet-cip.c +++ b/epan/dissectors/packet-cip.c @@ -3401,14 +3401,11 @@ dissect_cip_class_generic(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *ti; proto_tree *class_tree; - if( tree ) - { - /* Create display subtree for the protocol */ - ti = proto_tree_add_item(tree, proto_cip_class_generic, tvb, 0, -1, ENC_NA); - class_tree = proto_item_add_subtree( ti, ett_cip_class_generic ); + /* Create display subtree for the protocol */ + ti = proto_tree_add_item(tree, proto_cip_class_generic, tvb, 0, -1, ENC_NA); + class_tree = proto_item_add_subtree( ti, ett_cip_class_generic ); - dissect_cip_generic_data( class_tree, tvb, 0, tvb_length(tvb), pinfo, ti ); - } + dissect_cip_generic_data( class_tree, tvb, 0, tvb_length(tvb), pinfo, ti ); return tvb_length(tvb); } @@ -4918,14 +4915,11 @@ dissect_cip_class_mb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *ti; proto_tree *class_tree; - if( tree ) - { - /* Create display subtree for the protocol */ - ti = proto_tree_add_item(tree, proto_cip_class_mb, tvb, 0, -1, ENC_NA); - class_tree = proto_item_add_subtree( ti, ett_cip_class_mb ); + /* Create display subtree for the protocol */ + ti = proto_tree_add_item(tree, proto_cip_class_mb, tvb, 0, -1, ENC_NA); + class_tree = proto_item_add_subtree( ti, ett_cip_class_mb ); - dissect_cip_mb_data( class_tree, tvb, 0, tvb_length(tvb), pinfo ); - } + dissect_cip_mb_data( class_tree, tvb, 0, tvb_length(tvb), pinfo ); return tvb_length(tvb); } @@ -5274,14 +5268,11 @@ dissect_cip_class_cco(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *ti; proto_tree *class_tree; - if( tree ) - { - /* Create display subtree for the protocol */ - ti = proto_tree_add_item(tree, proto_cip_class_cco, tvb, 0, -1, ENC_NA); - class_tree = proto_item_add_subtree( ti, ett_cip_class_cco ); + /* Create display subtree for the protocol */ + ti = proto_tree_add_item(tree, proto_cip_class_cco, tvb, 0, -1, ENC_NA); + class_tree = proto_item_add_subtree( ti, ett_cip_class_cco ); - dissect_cip_cco_data( class_tree, tvb, 0, tvb_length(tvb), pinfo ); - } + dissect_cip_cco_data( class_tree, tvb, 0, tvb_length(tvb), pinfo ); return tvb_length(tvb); } diff --git a/epan/dissectors/packet-cipsafety.c b/epan/dissectors/packet-cipsafety.c index 09c19502b6..75910171c8 100644 --- a/epan/dissectors/packet-cipsafety.c +++ b/epan/dissectors/packet-cipsafety.c @@ -709,14 +709,11 @@ dissect_cip_class_s_supervisor(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr proto_item *ti; proto_tree *class_tree; - if( tree ) - { - /* Create display subtree for the protocol */ - ti = proto_tree_add_item(tree, proto_cip_class_s_supervisor, tvb, 0, -1, ENC_NA); - class_tree = proto_item_add_subtree( ti, ett_cip_class_s_supervisor ); + /* Create display subtree for the protocol */ + ti = proto_tree_add_item(tree, proto_cip_class_s_supervisor, tvb, 0, -1, ENC_NA); + class_tree = proto_item_add_subtree( ti, ett_cip_class_s_supervisor ); - dissect_cip_s_supervisor_data( class_tree, tvb, 0, tvb_length(tvb), pinfo ); - } + dissect_cip_s_supervisor_data( class_tree, tvb, 0, tvb_length(tvb), pinfo ); return tvb_length(tvb); } @@ -1289,14 +1286,11 @@ dissect_cip_class_s_validator(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre proto_item *ti; proto_tree *class_tree; - if( tree ) - { - /* Create display subtree for the protocol */ - ti = proto_tree_add_item(tree, proto_cip_class_s_validator, tvb, 0, -1, ENC_NA); - class_tree = proto_item_add_subtree( ti, ett_cip_class_s_validator ); + /* Create display subtree for the protocol */ + ti = proto_tree_add_item(tree, proto_cip_class_s_validator, tvb, 0, -1, ENC_NA); + class_tree = proto_item_add_subtree( ti, ett_cip_class_s_validator ); - dissect_cip_s_validator_data( class_tree, tvb, 0, tvb_length(tvb), pinfo ); - } + dissect_cip_s_validator_data( class_tree, tvb, 0, tvb_length(tvb), pinfo ); return tvb_length(tvb); } @@ -1416,6 +1410,9 @@ dissect_ack_byte( proto_tree *tree, tvbuff_t *tvb, int offset, packet_info *pinf ack_byte = tvb_get_guint8(tvb, offset); #endif + if (!tree) + return; + /* dissect Ack Byte bits */ ack_item = proto_tree_add_item(tree, hf_cipsafety_ack_byte, tvb, offset, 1, ENC_LITTLE_ENDIAN); ack_tree = proto_item_add_subtree( ack_item, ett_cipsafety_ack_byte); @@ -1616,14 +1613,11 @@ dissect_cipsafety(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *ti; proto_tree *safety_tree; - if( tree ) - { - /* Create display subtree for the protocol */ - ti = proto_tree_add_item(tree, proto_cipsafety, tvb, 0, -1, ENC_NA); - safety_tree = proto_item_add_subtree( ti, ett_cip_safety); + /* Create display subtree for the protocol */ + ti = proto_tree_add_item(tree, proto_cipsafety, tvb, 0, -1, ENC_NA); + safety_tree = proto_item_add_subtree( ti, ett_cip_safety); - dissect_cip_safety_data(safety_tree, ti, tvb, tvb_length(tvb), pinfo ); - } + dissect_cip_safety_data(safety_tree, ti, tvb, tvb_length(tvb), pinfo ); } static int dissect_sercosiii_link_error_count_p1p2(packet_info *pinfo, proto_tree *tree, proto_item *item, tvbuff_t *tvb, diff --git a/epan/dissectors/packet-dmx.c b/epan/dissectors/packet-dmx.c index 230187a3ed..429936a7c1 100644 --- a/epan/dissectors/packet-dmx.c +++ b/epan/dissectors/packet-dmx.c @@ -85,46 +85,43 @@ static void dissect_dmx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { tvbuff_t *next_tvb = NULL; + unsigned offset = 0; + guint8 start_code; col_set_str(pinfo->cinfo, COL_PROTOCOL, "DMX"); col_clear(pinfo->cinfo, COL_INFO); - if (tree != NULL) { - unsigned offset = 0; - guint8 start_code; - - start_code = tvb_get_guint8(tvb, offset); - proto_tree_add_item(tree, hf_dmx_start_code, tvb, - offset, 1, ENC_BIG_ENDIAN); - offset++; - - switch (start_code) { - case DMX_SC_DMX: - next_tvb = tvb_new_subset_remaining(tvb, offset); - call_dissector(dmx_chan_handle, next_tvb, pinfo, tree); - break; - case DMX_SC_TEXT: - next_tvb = tvb_new_subset_remaining(tvb, offset); - call_dissector(dmx_text_handle, next_tvb, pinfo, tree); - break; - case DMX_SC_TEST: - next_tvb = tvb_new_subset_remaining(tvb, offset); - call_dissector(dmx_test_handle, next_tvb, pinfo, tree); - break; - case DMX_SC_RDM: - next_tvb = tvb_new_subset_remaining(tvb, offset); - call_dissector(rdm_handle, next_tvb, pinfo, tree); - break; - case DMX_SC_SIP: - next_tvb = tvb_new_subset_remaining(tvb, offset); - call_dissector(dmx_sip_handle, next_tvb, pinfo, tree); - break; - default: - if (offset < tvb_length(tvb)) - proto_tree_add_item(tree, hf_dmx_frame_data, tvb, - offset, -1, ENC_NA); - break; - } + start_code = tvb_get_guint8(tvb, offset); + proto_tree_add_item(tree, hf_dmx_start_code, tvb, + offset, 1, ENC_BIG_ENDIAN); + offset++; + + switch (start_code) { + case DMX_SC_DMX: + next_tvb = tvb_new_subset_remaining(tvb, offset); + call_dissector(dmx_chan_handle, next_tvb, pinfo, tree); + break; + case DMX_SC_TEXT: + next_tvb = tvb_new_subset_remaining(tvb, offset); + call_dissector(dmx_text_handle, next_tvb, pinfo, tree); + break; + case DMX_SC_TEST: + next_tvb = tvb_new_subset_remaining(tvb, offset); + call_dissector(dmx_test_handle, next_tvb, pinfo, tree); + break; + case DMX_SC_RDM: + next_tvb = tvb_new_subset_remaining(tvb, offset); + call_dissector(rdm_handle, next_tvb, pinfo, tree); + break; + case DMX_SC_SIP: + next_tvb = tvb_new_subset_remaining(tvb, offset); + call_dissector(dmx_sip_handle, next_tvb, pinfo, tree); + break; + default: + if (offset < tvb_length(tvb)) + proto_tree_add_item(tree, hf_dmx_frame_data, tvb, + offset, -1, ENC_NA); + break; } } diff --git a/epan/dissectors/packet-dvb-data-mpe.c b/epan/dissectors/packet-dvb-data-mpe.c index e9b031df2e..21ef8b3e8e 100644 --- a/epan/dissectors/packet-dvb-data-mpe.c +++ b/epan/dissectors/packet-dvb-data-mpe.c @@ -84,9 +84,6 @@ dissect_dvb_data_mpe(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) col_set_str(pinfo->cinfo, COL_PROTOCOL, "DVB-DATA"); col_set_str(pinfo->cinfo, COL_INFO, "MultiProtocol Encapsulation"); - if (!tree) - return; - ti = proto_tree_add_item(tree, proto_dvb_data_mpe, tvb, offset, -1, ENC_NA); dvb_data_mpe_tree = proto_item_add_subtree(ti, ett_dvb_data_mpe); diff --git a/epan/dissectors/packet-llrp.c b/epan/dissectors/packet-llrp.c index e2dbe10e5b..e09957dfd2 100644 --- a/epan/dissectors/packet-llrp.c +++ b/epan/dissectors/packet-llrp.c @@ -842,33 +842,30 @@ dissect_llrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) type = tvb_get_ntohs(tvb, offset) & 0x03FF; col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", - val_to_str(type, message_types, "Unknown Type: %d")); + val_to_str(type, message_types, "Unknown Type: %d")); - if (tree) - { - ti = proto_tree_add_item(tree, proto_llrp, tvb, offset, -1, ENC_NA); - llrp_tree = proto_item_add_subtree(ti, ett_llrp); + ti = proto_tree_add_item(tree, proto_llrp, tvb, offset, -1, ENC_NA); + llrp_tree = proto_item_add_subtree(ti, ett_llrp); - proto_tree_add_item(llrp_tree, hf_llrp_version, tvb, offset, 1, ENC_NA); - proto_tree_add_item(llrp_tree, hf_llrp_type, tvb, offset, 2, ENC_BIG_ENDIAN); - offset += 2; + proto_tree_add_item(llrp_tree, hf_llrp_version, tvb, offset, 1, ENC_NA); + proto_tree_add_item(llrp_tree, hf_llrp_type, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; - ti = proto_tree_add_item(llrp_tree, hf_llrp_length, tvb, offset, 4, ENC_BIG_ENDIAN); - len = tvb_get_ntohl(tvb, offset); - if (len > tvb_reported_length(tvb)) - { - expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR, - "Incorrect length field: claimed %u, but only have %u.", - len, tvb_reported_length(tvb)); - } - offset += 4; + ti = proto_tree_add_item(llrp_tree, hf_llrp_length, tvb, offset, 4, ENC_BIG_ENDIAN); + len = tvb_get_ntohl(tvb, offset); + if (len > tvb_reported_length(tvb)) + { + expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR, + "Incorrect length field: claimed %u, but only have %u.", + len, tvb_reported_length(tvb)); + } + offset += 4; - proto_tree_add_item(llrp_tree, hf_llrp_id, tvb, offset, 4, ENC_BIG_ENDIAN); - offset += 4; + proto_tree_add_item(llrp_tree, hf_llrp_id, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; - if (match_strval(type, message_types)) - dissect_llrp_message(tvb, pinfo, llrp_tree, type, offset); - } + if (match_strval(type, message_types)) + dissect_llrp_message(tvb, pinfo, llrp_tree, type, offset); return tvb_length(tvb); } diff --git a/epan/dissectors/packet-moldudp.c b/epan/dissectors/packet-moldudp.c index e7be6b4e01..b480aa01df 100644 --- a/epan/dissectors/packet-moldudp.c +++ b/epan/dissectors/packet-moldudp.c @@ -147,40 +147,37 @@ dissect_moldudp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) else col_set_str(pinfo->cinfo, COL_INFO, "MoldUDP Messages"); - if (tree) + /* create display subtree for the protocol */ + ti = proto_tree_add_item(tree, proto_moldudp, + tvb, offset, -1, ENC_NA); + + moldudp_tree = proto_item_add_subtree(ti, ett_moldudp); + + proto_tree_add_item(moldudp_tree, hf_moldudp_session, + tvb, offset, MOLDUDP_SESSION_LEN, ENC_ASCII|ENC_NA); + offset += MOLDUDP_SESSION_LEN; + + sequence = tvb_get_letohl(tvb, offset); + proto_tree_add_item(moldudp_tree, hf_moldudp_sequence, + tvb, offset, MOLDUDP_SEQUENCE_LEN, ENC_LITTLE_ENDIAN); + offset += MOLDUDP_SEQUENCE_LEN; + + ti = proto_tree_add_item(moldudp_tree, hf_moldudp_count, + tvb, offset, MOLDUDP_COUNT_LEN, ENC_LITTLE_ENDIAN); + offset += MOLDUDP_COUNT_LEN; + + while (tvb_reported_length(tvb) >= offset + MOLDUDP_MSGLEN_LEN) { - /* create display subtree for the protocol */ - ti = proto_tree_add_item(tree, proto_moldudp, - tvb, offset, -1, ENC_NA); - - moldudp_tree = proto_item_add_subtree(ti, ett_moldudp); - - proto_tree_add_item(moldudp_tree, hf_moldudp_session, - tvb, offset, MOLDUDP_SESSION_LEN, ENC_ASCII|ENC_NA); - offset += MOLDUDP_SESSION_LEN; - - sequence = tvb_get_letohl(tvb, offset); - proto_tree_add_item(moldudp_tree, hf_moldudp_sequence, - tvb, offset, MOLDUDP_SEQUENCE_LEN, ENC_LITTLE_ENDIAN); - offset += MOLDUDP_SEQUENCE_LEN; - - ti = proto_tree_add_item(moldudp_tree, hf_moldudp_count, - tvb, offset, MOLDUDP_COUNT_LEN, ENC_LITTLE_ENDIAN); - offset += MOLDUDP_COUNT_LEN; - - while (tvb_reported_length(tvb) >= offset + MOLDUDP_MSGLEN_LEN) - { - offset += dissect_moldudp_msgblk(tvb, pinfo, moldudp_tree, - offset, sequence++); - real_count++; - } - - if (real_count != count) - { - expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR, - "Invalid Message Count (claimed %u, found %u)", - count, real_count); - } + offset += dissect_moldudp_msgblk(tvb, pinfo, moldudp_tree, + offset, sequence++); + real_count++; + } + + if (real_count != count) + { + expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR, + "Invalid Message Count (claimed %u, found %u)", + count, real_count); } /* Return the amount of data this dissector was able to dissect */ diff --git a/epan/dissectors/packet-moldudp64.c b/epan/dissectors/packet-moldudp64.c index 79b186bdd8..df751eeb84 100644 --- a/epan/dissectors/packet-moldudp64.c +++ b/epan/dissectors/packet-moldudp64.c @@ -148,48 +148,45 @@ dissect_moldudp64(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) else col_set_str(pinfo->cinfo, COL_INFO, "MoldUDP64 Messages"); - if (tree) - { - /* create display subtree for the protocol */ - ti = proto_tree_add_item(tree, proto_moldudp64, - tvb, offset, -1, ENC_NA); + /* create display subtree for the protocol */ + ti = proto_tree_add_item(tree, proto_moldudp64, + tvb, offset, -1, ENC_NA); - moldudp64_tree = proto_item_add_subtree(ti, ett_moldudp64); + moldudp64_tree = proto_item_add_subtree(ti, ett_moldudp64); - proto_tree_add_item(moldudp64_tree, hf_moldudp64_session, - tvb, offset, MOLDUDP64_SESSION_LEN, ENC_ASCII|ENC_NA); - offset += MOLDUDP64_SESSION_LEN; + proto_tree_add_item(moldudp64_tree, hf_moldudp64_session, + tvb, offset, MOLDUDP64_SESSION_LEN, ENC_ASCII|ENC_NA); + offset += MOLDUDP64_SESSION_LEN; - proto_tree_add_item(moldudp64_tree, hf_moldudp64_sequence, - tvb, offset, MOLDUDP64_SEQUENCE_LEN, ENC_BIG_ENDIAN); - offset += MOLDUDP64_SEQUENCE_LEN; + proto_tree_add_item(moldudp64_tree, hf_moldudp64_sequence, + tvb, offset, MOLDUDP64_SEQUENCE_LEN, ENC_BIG_ENDIAN); + offset += MOLDUDP64_SEQUENCE_LEN; - ti = proto_tree_add_item(moldudp64_tree, hf_moldudp64_count, - tvb, offset, MOLDUDP64_COUNT_LEN, ENC_BIG_ENDIAN); - offset += MOLDUDP64_COUNT_LEN; + ti = proto_tree_add_item(moldudp64_tree, hf_moldudp64_count, + tvb, offset, MOLDUDP64_COUNT_LEN, ENC_BIG_ENDIAN); + offset += MOLDUDP64_COUNT_LEN; - while (tvb_reported_length(tvb) >= offset + MOLDUDP64_MSGLEN_LEN) - { - offset += dissect_moldudp64_msgblk(tvb, pinfo, moldudp64_tree, - offset, sequence++); - real_count++; - } + while (tvb_reported_length(tvb) >= offset + MOLDUDP64_MSGLEN_LEN) + { + offset += dissect_moldudp64_msgblk(tvb, pinfo, moldudp64_tree, + offset, sequence++); + real_count++; + } - if (count == MOLDUDP64_ENDOFSESS) - { - if (real_count != 0) - { - expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR, - "End Of Session packet with extra data."); - } - } - else if (real_count != count) + if (count == MOLDUDP64_ENDOFSESS) + { + if (real_count != 0) { expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR, - "Invalid Message Count (claimed %u, found %u)", - count, real_count); + "End Of Session packet with extra data."); } } + else if (real_count != count) + { + expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_ERROR, + "Invalid Message Count (claimed %u, found %u)", + count, real_count); + } /* Return the amount of data this dissector was able to dissect */ return tvb_length(tvb); diff --git a/epan/dissectors/packet-mpeg-pat.c b/epan/dissectors/packet-mpeg-pat.c index a25adabebe..1afabb6093 100644 --- a/epan/dissectors/packet-mpeg-pat.c +++ b/epan/dissectors/packet-mpeg-pat.c @@ -84,9 +84,6 @@ dissect_mpeg_pat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) ti = proto_tree_add_item(tree, proto_mpeg_pat, tvb, offset, -1, ENC_NA); mpeg_pat_tree = proto_item_add_subtree(ti, ett_mpeg_pat); - if (!tree) - return; - offset += packet_mpeg_sect_header(tvb, offset, mpeg_pat_tree, &length, NULL); length -= 4; diff --git a/epan/dissectors/packet-mpeg-sect.c b/epan/dissectors/packet-mpeg-sect.c index 1c3acf8bb2..44ec68427c 100644 --- a/epan/dissectors/packet-mpeg-sect.c +++ b/epan/dissectors/packet-mpeg-sect.c @@ -292,20 +292,16 @@ dissect_mpeg_sect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) return; /* If no dissector is registered, use the common one */ - if (tree) { - - col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPEG SECT"); - col_add_fstr(pinfo->cinfo, COL_INFO, "Table ID 0x%02x", table_id); + col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPEG SECT"); + col_add_fstr(pinfo->cinfo, COL_INFO, "Table ID 0x%02x", table_id); - ti = proto_tree_add_item(tree, proto_mpeg_sect, tvb, offset, -1, ENC_NA); - mpeg_sect_tree = proto_item_add_subtree(ti, ett_mpeg_sect); + ti = proto_tree_add_item(tree, proto_mpeg_sect, tvb, offset, -1, ENC_NA); + mpeg_sect_tree = proto_item_add_subtree(ti, ett_mpeg_sect); - proto_item_append_text(ti, " Table_ID=0x%02x", table_id); + proto_item_append_text(ti, " Table_ID=0x%02x", table_id); - packet_mpeg_sect_header(tvb, offset, mpeg_sect_tree, - §ion_length, &syntax_indicator); - - } + packet_mpeg_sect_header(tvb, offset, mpeg_sect_tree, + §ion_length, &syntax_indicator); if (syntax_indicator) packet_mpeg_sect_crc(tvb, pinfo, mpeg_sect_tree, 0, (section_length-1)); diff --git a/epan/dissectors/packet-openwire.c b/epan/dissectors/packet-openwire.c index 66954d6286..bf5a8e7071 100644 --- a/epan/dissectors/packet-openwire.c +++ b/epan/dissectors/packet-openwire.c @@ -1308,9 +1308,11 @@ dissect_openwire_command(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, in static void dissect_openwire(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - gint offset = 0; - guint8 iCommand; - proto_tree *openwireroot_tree = NULL; + gint offset = 0; + guint8 iCommand; + proto_tree *openwireroot_tree = NULL; + proto_item *ti; + gboolean caching; col_set_str(pinfo->cinfo, COL_PROTOCOL, "OpenWire"); @@ -1327,39 +1329,32 @@ dissect_openwire(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) detect_protocol_options(tvb, pinfo, offset, iCommand); - if (tree) - { - proto_item *ti; - gboolean caching; + ti = proto_tree_add_item(tree, proto_openwire, tvb, offset, -1, ENC_NA); + proto_item_append_text(ti, " (%s)", val_to_str_ext(iCommand, &openwire_opcode_vals_ext, "Unknown (0x%02x)")); + openwireroot_tree = proto_item_add_subtree(ti, ett_openwire); - ti = proto_tree_add_item(tree, proto_openwire, tvb, offset, -1, ENC_NA); - proto_item_append_text(ti, " (%s)", val_to_str_ext(iCommand, &openwire_opcode_vals_ext, "Unknown (0x%02x)")); - openwireroot_tree = proto_item_add_subtree(ti, ett_openwire); + proto_tree_add_item(openwireroot_tree, hf_openwire_length, tvb, offset + 0, 4, ENC_BIG_ENDIAN); - proto_tree_add_item(openwireroot_tree, hf_openwire_length, tvb, offset + 0, 4, ENC_BIG_ENDIAN); - - /* Abort dissection if tight encoding is enabled*/ - if (iCommand != OPENWIRE_WIREFORMAT_INFO && retrieve_tight(pinfo) == TRUE) - { - proto_tree_add_item(openwireroot_tree, hf_openwire_command, tvb, offset + 4, 1, ENC_BIG_ENDIAN); - expert_add_info_format(pinfo, openwireroot_tree, PI_UNDECODED, PI_NOTE, - "OpenWire tight encoding not supported by Wireshark, use wireFormat.tightEncodingEnabled=false"); - return; - } - - caching = retrieve_caching(pinfo); - if (caching) - { - proto_tree_add_boolean(openwireroot_tree, hf_openwire_cached_enabled, tvb, offset, 0, caching); - } + /* Abort dissection if tight encoding is enabled*/ + if (iCommand != OPENWIRE_WIREFORMAT_INFO && retrieve_tight(pinfo) == TRUE) + { + proto_tree_add_item(openwireroot_tree, hf_openwire_command, tvb, offset + 4, 1, ENC_BIG_ENDIAN); + expert_add_info_format(pinfo, openwireroot_tree, PI_UNDECODED, PI_NOTE, + "OpenWire tight encoding not supported by Wireshark, use wireFormat.tightEncodingEnabled=false"); + return; + } - offset += 4; - offset += dissect_openwire_command(tvb, pinfo, openwireroot_tree, offset, iCommand); - if (tvb_length_remaining(tvb, offset) > 0) - { - expert_add_info_format(pinfo, tree, PI_UNDECODED, PI_NOTE, "OpenWire command fields unknown to Wireshark: %d", iCommand); - } + caching = retrieve_caching(pinfo); + if (caching) + { + proto_tree_add_boolean(openwireroot_tree, hf_openwire_cached_enabled, tvb, offset, 0, caching); + } + offset += 4; + offset += dissect_openwire_command(tvb, pinfo, openwireroot_tree, offset, iCommand); + if (tvb_length_remaining(tvb, offset) > 0) + { + expert_add_info_format(pinfo, tree, PI_UNDECODED, PI_NOTE, "OpenWire command fields unknown to Wireshark: %d", iCommand); } } } |