Skip to content

Commit

Permalink
Fix: Handle undefined direction in alerts
Browse files Browse the repository at this point in the history
In alerts with the "Filter count changed" condition, the check now
always falls back to checking if the count increased if the "direction"
condition data is not defined.
Without the fix having it undefined could cause a segmentation fault.
  • Loading branch information
timopollmeier committed May 23, 2023
1 parent 41a645d commit d861d45
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -14322,7 +14322,10 @@ condition_met (task_t task, report_t report, alert_t alert,
{
/* Same as "increased". */
if (cmp >= count)
return 1;
{
free (filter_id);
return 1;
}
}
else if (((strcasecmp (direction, "changed") == 0)
&& (abs (cmp) >= count))
Expand All @@ -14341,7 +14344,16 @@ condition_met (task_t task, report_t report, alert_t alert,
g_debug ("direction: %s", direction);
g_debug ("last_count: %i", last_count);
g_debug ("second_last_count NULL");
if (((strcasecmp (direction, "changed") == 0)
if (direction == NULL)
{
/* Same as "increased". */
if (last_count > 0)
{
free (filter_id);
return 1;
}
}
else if (((strcasecmp (direction, "changed") == 0)
|| (strcasecmp (direction, "increased") == 0))
&& (last_count > 0))
{
Expand Down

0 comments on commit d861d45

Please sign in to comment.