aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mathieson <martin.mathieson@keysight.com>2020-02-14 21:13:56 +0000
committerAnders Broman <a.broman58@gmail.com>2020-02-15 11:06:41 +0000
commite30f0d09208b01a7dd3d685b612110d16683f045 (patch)
tree01b30244e1f515ac3a3e3c7163ef2e8175660d00
parent36e5f9539e982abf420bf8f044bd1a2c45e22919 (diff)
Some issues spotted by PVS-Studio in bug 16335. Many more remain
Change-Id: If856e25af8e33eeef5b9e595f1f6820459892b17 Reviewed-on: https://code.wireshark.org/review/36110 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--epan/dissectors/packet-catapult-dct2000.c1
-rw-r--r--epan/dissectors/packet-kafka.c6
-rw-r--r--epan/dissectors/packet-mac-lte.c12
-rw-r--r--epan/dissectors/packet-pdcp-lte.c2
-rw-r--r--epan/dissectors/packet-rlc-lte.c2
-rw-r--r--epan/dissectors/packet-snort.c4
-rw-r--r--epan/dissectors/packet-tftp.c2
-rw-r--r--epan/dissectors/packet-umts_fp.c12
-rw-r--r--ui/tap-rlc-graph.c3
9 files changed, 18 insertions, 26 deletions
diff --git a/epan/dissectors/packet-catapult-dct2000.c b/epan/dissectors/packet-catapult-dct2000.c
index 43e640a738..83bbbcc418 100644
--- a/epan/dissectors/packet-catapult-dct2000.c
+++ b/epan/dissectors/packet-catapult-dct2000.c
@@ -654,7 +654,6 @@ static gboolean find_sctpprim_variant3_data_offset(tvbuff_t *tvb, int *data_offs
break;
case 0x0d00: /* StreamNum */
- *dest_port_offset = offset;
offset += 2;
break;
diff --git a/epan/dissectors/packet-kafka.c b/epan/dissectors/packet-kafka.c
index 0beb219692..ba9932c4da 100644
--- a/epan/dissectors/packet-kafka.c
+++ b/epan/dissectors/packet-kafka.c
@@ -2056,9 +2056,7 @@ dissect_kafka_metadata_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr
if (api_version >= 8) {
proto_tree_add_item(tree, hf_kafka_include_cluster_authorized_ops, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
- }
- if (api_version >= 8) {
proto_tree_add_item(tree, hf_kafka_include_topic_authorized_ops, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
}
@@ -2786,9 +2784,7 @@ dissect_kafka_fetch_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (api_version >= 7) {
proto_tree_add_item(tree, hf_kafka_fetch_session_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
- }
- if (api_version >= 7) {
proto_tree_add_item(tree, hf_kafka_fetch_session_epoch, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
@@ -2924,9 +2920,7 @@ dissect_kafka_fetch_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
if (api_version >= 7) {
offset = dissect_kafka_error(tvb, pinfo, tree, offset);
- }
- if (api_version >= 7) {
proto_tree_add_item(tree, hf_kafka_fetch_session_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
diff --git a/epan/dissectors/packet-mac-lte.c b/epan/dissectors/packet-mac-lte.c
index 249fb91ce1..0827aa987e 100644
--- a/epan/dissectors/packet-mac-lte.c
+++ b/epan/dissectors/packet-mac-lte.c
@@ -6094,7 +6094,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
}
else {
/* There is no padding at the end of the frame */
- if (!is_truncated && (offset < p_mac_lte_info->length)) {
+ if (offset < p_mac_lte_info->length) {
/* There is a problem if we haven't used all of the PDU */
expert_add_info_format(pinfo, pdu_ti, &ei_mac_lte_context_length,
"%s PDU for UE %u is shorter than reported length (reported=%u, actual=%u)",
@@ -6102,7 +6102,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
p_mac_lte_info->ueid, p_mac_lte_info->length, offset);
}
- if (!is_truncated && (offset > p_mac_lte_info->length)) {
+ if (offset > p_mac_lte_info->length) {
/* There is a problem if the PDU is longer than reported */
expert_add_info_format(pinfo, pdu_ti, &ei_mac_lte_context_length,
"%s PDU for UE %u is longer than reported length (reported=%u, actual=%u)",
@@ -6526,14 +6526,14 @@ static void dissect_mch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, pro
}
else {
/* There is no padding at the end of the frame */
- if (!is_truncated && (offset < p_mac_lte_info->length)) {
+ if (offset < p_mac_lte_info->length) {
/* There is a problem if we haven't used all of the PDU */
expert_add_info_format(pinfo, pdu_ti, &ei_mac_lte_context_length,
"PDU is shorter than reported length (reported=%u, actual=%u)",
p_mac_lte_info->length, offset);
}
- if (!is_truncated && (offset > p_mac_lte_info->length)) {
+ if (offset > p_mac_lte_info->length) {
/* There is a problem if the PDU is longer than reported */
expert_add_info_format(pinfo, pdu_ti, &ei_mac_lte_context_length,
"PDU is longer than reported length (reported=%u, actual=%u)",
@@ -6881,14 +6881,14 @@ static void dissect_slsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
}
} else {
/* There is no padding at the end of the frame */
- if (!is_truncated && (offset < p_mac_lte_info->length)) {
+ if (offset < p_mac_lte_info->length) {
/* There is a problem if we haven't used all of the PDU */
expert_add_info_format(pinfo, pdu_ti, &ei_mac_lte_context_length,
"SL-SCH PDU for UE %u is shorter than reported length (reported=%u, actual=%u)",
p_mac_lte_info->ueid, p_mac_lte_info->length, offset);
}
- if (!is_truncated && (offset > p_mac_lte_info->length)) {
+ if (offset > p_mac_lte_info->length) {
/* There is a problem if the PDU is longer than reported */
expert_add_info_format(pinfo, pdu_ti, &ei_mac_lte_context_length,
"SL-SCH PDU for UE %u is longer than reported length (reported=%u, actual=%u)",
diff --git a/epan/dissectors/packet-pdcp-lte.c b/epan/dissectors/packet-pdcp-lte.c
index 79e37b4cf5..0b02eca9e4 100644
--- a/epan/dissectors/packet-pdcp-lte.c
+++ b/epan/dissectors/packet-pdcp-lte.c
@@ -1932,7 +1932,7 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/**********************************/
/* User-plane messages */
- gboolean pdu_type = (first_byte & 0x80) >> 7;
+ guint8 pdu_type = (first_byte & 0x80) >> 7;
/* Data/Control flag */
proto_tree_add_item(pdcp_tree, hf_pdcp_lte_data_control, tvb, offset, 1, ENC_BIG_ENDIAN);
diff --git a/epan/dissectors/packet-rlc-lte.c b/epan/dissectors/packet-rlc-lte.c
index d673a56c11..1556ef129a 100644
--- a/epan/dissectors/packet-rlc-lte.c
+++ b/epan/dissectors/packet-rlc-lte.c
@@ -2449,7 +2449,7 @@ static void dissect_rlc_lte_am_status_pdu(tvbuff_t *tvb,
/* Reset this flag here */
e2 = 0;
}
- } while (e1 || e2);
+ } while (e1);
if (nack_count > 0) {
proto_item *count_ti = proto_tree_add_uint(tree, hf_rlc_lte_am_nacks, tvb, 0, 1, nack_count);
diff --git a/epan/dissectors/packet-snort.c b/epan/dissectors/packet-snort.c
index 5a9985c42e..8b6158adbb 100644
--- a/epan/dissectors/packet-snort.c
+++ b/epan/dissectors/packet-snort.c
@@ -898,7 +898,7 @@ static void snort_show_alert(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo
unsigned int converted_content_length = 0;
int content_hf_item;
char *content_text_template;
- gboolean attempt_match;
+ gboolean attempt_match = FALSE;
/* Choose type of content field to add */
switch (rule->contents[n].content_type) {
@@ -1275,10 +1275,10 @@ static void snort_start(void)
return;
}
+ /* Don't start if already running */
if (current_session.running) {
return;
}
- current_session.running = FALSE;
/* Reset global stats */
reset_global_rule_stats(g_snort_config);
diff --git a/epan/dissectors/packet-tftp.c b/epan/dissectors/packet-tftp.c
index 99d3422c25..eb9e1f6e40 100644
--- a/epan/dissectors/packet-tftp.c
+++ b/epan/dissectors/packet-tftp.c
@@ -218,7 +218,7 @@ tftp_eo_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const
/* Free up unnecessary memory */
g_free(eo_info->filename);
- /* Pass out the contigous data and length already accumulated. */
+ /* Pass out the contiguous data and length already accumulated. */
entry->payload_len = eo_info->payload_len;
entry->payload_data = eo_info->payload_data;
diff --git a/epan/dissectors/packet-umts_fp.c b/epan/dissectors/packet-umts_fp.c
index 324868abfb..72d382682e 100644
--- a/epan/dissectors/packet-umts_fp.c
+++ b/epan/dissectors/packet-umts_fp.c
@@ -3549,9 +3549,8 @@ dissect_hsdsch_type_2_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree
}
}
- if (header_length == 0) {
- header_length = offset;
- }
+ header_length = offset;
+
/**********************************************/
/* Optional fields indicated by earlier flags */
if (drt_present) {
@@ -3812,9 +3811,8 @@ void dissect_hsdsch_common_channel_info(tvbuff_t *tvb, packet_info *pinfo, proto
offset - block_header_start_offset);
}
}
- if (header_length == 0) {
- header_length = offset;
- }
+
+ header_length = offset;
/**********************************************/
/* Optional fields indicated by earlier flags */
@@ -4938,7 +4936,7 @@ heur_dissect_fp_hsdsch_type_2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
return FALSE;
}
- captured_length = tvb_reported_length(tvb);
+ captured_length = tvb_captured_length(tvb);
reported_length = tvb_reported_length(tvb);
/* Lengths limit: header size + at least 1 PDU Block Header + CRC Payload size */
if (captured_length < 11) {
diff --git a/ui/tap-rlc-graph.c b/ui/tap-rlc-graph.c
index b2ea3af567..26f2e97353 100644
--- a/ui/tap-rlc-graph.c
+++ b/ui/tap-rlc-graph.c
@@ -36,7 +36,8 @@ gboolean compare_rlc_headers(guint16 ueid1, guint16 channelType1, guint16 channe
(rlcMode1 == rlcMode2);
}
else {
- if (frameIsControl && (rlcMode1 == RLC_AM_MODE) && (rlcMode2 == RLC_AM_MODE)) {
+ /* Control case */
+ if ((rlcMode1 == RLC_AM_MODE) && (rlcMode2 == RLC_AM_MODE)) {
return ((direction1 != direction2) &&
(ueid1 == ueid2) &&
(channelType1 == channelType2) &&