aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-snort.c
diff options
context:
space:
mode:
authorMartin Mathieson <martin.mathieson@keysight.com>2020-05-03 00:33:51 +0100
committerGuy Harris <gharris@sonic.net>2020-05-03 00:26:33 +0000
commitb99dcf0593e105bf46603e714d295b04b72c28bd (patch)
tree831e031678e238e1caf55a084009e1ed3dbe5e66 /epan/dissectors/packet-snort.c
parentbab7b8d638ba0ac6901d4295586d1f9865cbbb76 (diff)
Fix some issues seen with a fresh run of PVS Studio
/opt/SourceCode/wireshark/epan/dissectors/packet-aoe.c 328 warn V581 The conditional expressions of the 'if' statements situated alongside each other are identical. Check lines: 323, 328. /opt/SourceCode/wireshark/epan/dissectors/packet-aprs.c 1148 warn V1037 Two or more case-branches perform the same actions. Check lines: 1148, 1161 /opt/SourceCode/wireshark/epan/dissectors/packet-lsd.c 127 err V547 Expression 'strlen("cookie") == 0' is always false. /opt/SourceCode/wireshark/epan/dissectors/packet-rpc.c 3385 warn V547 Expression 'conversation == NULL' is always true. /opt/SourceCode/wireshark/epan/dissectors/packet-snort-config.c 465 note V576 Incorrect format. Consider checking the fourth actual argument of the 'g_snprintf' function. Under certain conditions the pointer can be null. /opt/SourceCode/wireshark/epan/dissectors/packet-snort.c 630 warn V768 The variable 'condition' is of enum type. It is odd that it is used as a variable of a Boolean-type. /opt/SourceCode/wireshark/epan/dissectors/packet-snort.c 969 warn V547 Expression '!attempt_match' is always false. Bug: 16335 Change-Id: I93bbc40f0467ebaab74335f6edc7d60e1c600a94 Reviewed-on: https://code.wireshark.org/review/37044 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
Diffstat (limited to 'epan/dissectors/packet-snort.c')
-rw-r--r--epan/dissectors/packet-snort.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/epan/dissectors/packet-snort.c b/epan/dissectors/packet-snort.c
index 8b6158adbb..c0ed6860dd 100644
--- a/epan/dissectors/packet-snort.c
+++ b/epan/dissectors/packet-snort.c
@@ -627,7 +627,7 @@ static gboolean snort_fast_output(GIOChannel *source, GIOCondition condition, gp
g_free(old_buf);
}
- if (condition) {
+ if ((condition == G_IO_ERR) || (condition == G_IO_HUP) || (condition == G_IO_NVAL)) {
/* Will report errors (hung-up, or error) */
/* g_print("snort_fast_output() cond: (h:%d,e:%d,r:%d)\n",
@@ -898,24 +898,20 @@ 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 = FALSE;
/* Choose type of content field to add */
switch (rule->contents[n].content_type) {
case Content:
content_hf_item = hf_snort_content;
content_text_template = "Content: \"%s\"";
- attempt_match = TRUE;
break;
case UriContent:
content_hf_item = hf_snort_uricontent;
content_text_template = "Uricontent: \"%s\"";
- attempt_match = TRUE;
break;
case Pcre:
content_hf_item = hf_snort_pcre;
content_text_template = "Pcre: \"%s\"";
- attempt_match = TRUE;
break;
default:
continue;
@@ -923,7 +919,7 @@ static void snort_show_alert(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo
/* Will only try to look for content in packet ourselves if not
a negated content entry (i.e. beginning with '!') */
- if (attempt_match && !rule->contents[n].negation) {
+ if (!rule->contents[n].negation) {
/* Look up offset of match. N.B. would only expect to see on first content... */
guint distance_to_add = 0;
@@ -966,10 +962,6 @@ static void snort_show_alert(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo
content_start_match = content_last_match_end;
}
- if (!attempt_match) {
- proto_item_append_text(ti, " (no match attempt made)");
- }
-
/* Show (only as text) attributes of content field */
if (rule->contents[n].fastpattern) {
proto_item_append_text(ti, " (fast_pattern)");
@@ -1010,7 +1002,7 @@ static void snort_show_alert(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo
proto_item_append_text(ti, " (http_user_agent)");
}
- if (attempt_match && !rule->contents[n].negation && !match_found) {
+ if (!rule->contents[n].negation && !match_found) {
/* Useful for debugging, may also happen when Snort is reassembling.. */
/* TODO: not sure why, but PCREs might not be found first time through, but will be
* found later, with the result that there will be 'not located' expert warnings,