aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorMartin Mathieson <martin.mathieson@keysight.com>2020-02-15 23:00:17 +0000
committerAnders Broman <a.broman58@gmail.com>2020-02-16 11:51:55 +0000
commit7e02165453f78dc2196d66d6167d8fdeebdf2cb3 (patch)
tree4fc51bc963d4c38f03fc1790dfa63517c041cb12 /epan
parentfbd88490dd05aa76d5f70b81cbc6fdad83313800 (diff)
More issues spotted by PVS-Studio in bug 16335.
Only the change to packet-imap.c really represents a bug. Change-Id: Ie270f97f3d94c338ea3c84a712f8f4d43ffd36f4 Reviewed-on: https://code.wireshark.org/review/36115 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-ber.c15
-rw-r--r--epan/dissectors/packet-ftp.c8
-rw-r--r--epan/dissectors/packet-imap.c2
-rw-r--r--epan/dissectors/packet-sdp.c2
-rw-r--r--epan/dissectors/packet-sip.c1
-rw-r--r--epan/dissectors/packet-snort-config.c2
6 files changed, 10 insertions, 20 deletions
diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c
index 9990895ce8..1606f828dc 100644
--- a/epan/dissectors/packet-ber.c
+++ b/epan/dissectors/packet-ber.c
@@ -1829,7 +1829,7 @@ dissect_ber_null(gboolean implicit_tag, asn1_ctx_t *actx, proto_tree *tree, tvbu
offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &ber_class, &pc, &tag);
identifier_len = offset - identifier_offset;
if (pc ||
- (!implicit_tag && ((ber_class != BER_CLASS_UNI) || (tag != BER_UNI_TAG_NULL)))) {
+ ((ber_class != BER_CLASS_UNI) || (tag != BER_UNI_TAG_NULL))) {
proto_tree_add_expert_format(
tree, actx->pinfo, &ei_ber_expected_null,
tvb, identifier_offset, identifier_len,
@@ -2205,7 +2205,7 @@ proto_tree_add_debug_text(tree, "SEQUENCE dissect_ber_sequence(%s) entered\n", n
/* sanity check: we only handle Constructed Universal Sequences */
if ((classx != BER_CLASS_APP) && (classx != BER_CLASS_PRI)) {
if (!pcx
- || (!implicit_tag && ((classx != BER_CLASS_UNI) || (tagx != BER_UNI_TAG_SEQUENCE)))) {
+ || ((classx != BER_CLASS_UNI) || (tagx != BER_UNI_TAG_SEQUENCE))) {
tvb_ensure_bytes_exist(tvb, hoffset, 2);
cause = proto_tree_add_expert_format(
tree, actx->pinfo, &ei_ber_expected_sequence,
@@ -2565,8 +2565,7 @@ proto_tree_add_debug_text(tree, "SET dissect_ber_set(%s) entered\n", name);
/* sanity check: we only handle Constructed Universal Sets */
if ((classx != BER_CLASS_APP) && (classx != BER_CLASS_PRI)) {
if (!pcx
- || (!implicit_tag && ((classx != BER_CLASS_UNI)
- || (tagx != BER_UNI_TAG_SET)))) {
+ || ((classx != BER_CLASS_UNI) || (tagx != BER_UNI_TAG_SET))) {
tvb_ensure_bytes_exist(tvb, hoffset, 2);
cause = proto_tree_add_expert_format(
tree, actx->pinfo, &ei_ber_expected_set,
@@ -3375,8 +3374,7 @@ proto_tree_add_debug_text(tree, "SQ OF dissect_ber_sq_of(%s) entered\n", name);
/* sanity check: we only handle Constructed Universal Sequences */
if ((classx != BER_CLASS_APP) && (classx != BER_CLASS_PRI)) {
if (!pcx
- || (!implicit_tag && ((classx != BER_CLASS_UNI)
- || (tagx != type)))) {
+ || ((classx != BER_CLASS_UNI) || (tagx != type))) {
tvb_ensure_bytes_exist(tvb, hoffsetx, 2);
causex = proto_tree_add_expert_format(
tree, actx->pinfo,
@@ -3635,8 +3633,7 @@ dissect_ber_GeneralizedTime(gboolean implicit_tag, asn1_ctx_t *actx, proto_tree
end_offset = offset+len;
/* sanity check. we only handle universal/generalized time */
- if ( (ber_class != BER_CLASS_UNI)
- || (tag != BER_UNI_TAG_GeneralizedTime)) {
+ if ( (ber_class != BER_CLASS_UNI) || (tag != BER_UNI_TAG_GeneralizedTime)) {
tvb_ensure_bytes_exist(tvb, hoffset, 2);
cause = proto_tree_add_expert_format(
tree, actx->pinfo, &ei_ber_expected_generalized_time,
@@ -3990,7 +3987,7 @@ dissect_ber_constrained_bitstring(gboolean implicit_tag, asn1_ctx_t *actx, proto
So here we relax it for APPLICATION tags. CONTEXT tags may
still cause a problem. */
- if (!implicit_tag && (ber_class != BER_CLASS_APP)) {
+ if (ber_class != BER_CLASS_APP) {
if ((ber_class != BER_CLASS_UNI)
|| (tag != BER_UNI_TAG_BITSTRING)) {
tvb_ensure_bytes_exist(tvb, hoffset, 2);
diff --git a/epan/dissectors/packet-ftp.c b/epan/dissectors/packet-ftp.c
index abf1d0cf75..9a0237beea 100644
--- a/epan/dissectors/packet-ftp.c
+++ b/epan/dissectors/packet-ftp.c
@@ -1037,17 +1037,13 @@ dissect_ftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
if (strncmp(p_ftp_conv->last_command, "CWD ", 4) == 0) {
process_cwd_success(p_ftp_conv, p_ftp_conv->last_command+4);
/* Update path in packet */
- if (!pinfo->fd->visited) {
- store_directory_in_packet(pinfo, p_ftp_conv);
- }
+ store_directory_in_packet(pinfo, p_ftp_conv);
}
/* Change Directory Up command (i.e. "CWD ..") */
else if (strncmp(p_ftp_conv->last_command, "CDUP", 4) == 0) {
process_cwd_success(p_ftp_conv, "..");
/* Update path in packet */
- if (!pinfo->fd->visited) {
- store_directory_in_packet(pinfo, p_ftp_conv);
- }
+ store_directory_in_packet(pinfo, p_ftp_conv);
}
}
}
diff --git a/epan/dissectors/packet-imap.c b/epan/dissectors/packet-imap.c
index 02ae519329..fa14a542a1 100644
--- a/epan/dissectors/packet-imap.c
+++ b/epan/dissectors/packet-imap.c
@@ -501,7 +501,7 @@ dissect_imap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
uidlen = linelen - (next_token - offset);
uid_offset = next_token;
uid_tokenlen = tvb_get_token_len(tvb, next_token, uidlen, &uid_next_token, FALSE);
- if (tokenlen != 0) {
+ if (uid_tokenlen != 0) {
proto_tree_add_item(reqresp_tree, hf_imap_request_command, tvb, uid_offset, uid_tokenlen, ENC_ASCII|ENC_NA);
hidden_item = proto_tree_add_item(reqresp_tree, hf_imap_command, tvb, offset, tokenlen, ENC_ASCII | ENC_NA);
proto_item_set_hidden(hidden_item);
diff --git a/epan/dissectors/packet-sdp.c b/epan/dissectors/packet-sdp.c
index f106fe552c..7deb9c7cd2 100644
--- a/epan/dissectors/packet-sdp.c
+++ b/epan/dissectors/packet-sdp.c
@@ -2725,8 +2725,6 @@ dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
if (NULL != sdp_data.ed137_fid) {
col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", sdp_data.ed137_fid);
- if (strlen(sdp_pi->summary_str))
- g_strlcat(sdp_pi->summary_str, " ", 50);
g_strlcat(sdp_pi->summary_str, sdp_data.ed137_fid, 50);
}
if (NULL != sdp_data.ed137_txrxmode) {
diff --git a/epan/dissectors/packet-sip.c b/epan/dissectors/packet-sip.c
index 114a8e615b..5a52c347e4 100644
--- a/epan/dissectors/packet-sip.c
+++ b/epan/dissectors/packet-sip.c
@@ -3540,7 +3540,6 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info
* we just do this to find the blank line separating the
* headers from the message body.
*/
- next_offset = offset;
content_length = -1;
while (remaining_length > 0) {
gint line_end_offset;
diff --git a/epan/dissectors/packet-snort-config.c b/epan/dissectors/packet-snort-config.c
index 2afe8e0b99..dfbf15b83d 100644
--- a/epan/dissectors/packet-snort-config.c
+++ b/epan/dissectors/packet-snort-config.c
@@ -31,7 +31,7 @@ static char *skipWhiteSpace(char *source, int *accumulated_offset)
int offset = 0;
/* Skip any leading whitespace */
- while (source[offset] != '\0' && source[offset] == ' ') {
+ while ((source[offset] == ' ') || (source[offset] == '\t')) {
offset++;
}