diff --git a/src/detect-engine-threshold.c b/src/detect-engine-threshold.c index 18f75fe672..efd9513897 100644 --- a/src/detect-engine-threshold.c +++ b/src/detect-engine-threshold.c @@ -171,7 +171,10 @@ static DetectThresholdEntry* ThresholdTimeoutCheck(DetectThresholdEntry *head, s DetectThresholdEntry *new_head = head; while (tmp != NULL) { - if ((tv->tv_sec - tmp->tv_sec1) <= tmp->seconds) { + /* check if the 'check' timestamp is not before the creation ts. + * This can happen due to the async nature of the host timeout + * code that also calls this code from a management thread. */ + if (((uint32_t)tv->tv_sec < tmp->tv_sec1) || (tv->tv_sec - tmp->tv_sec1) <= tmp->seconds) { prev = tmp; tmp = tmp->next; continue;