Skip to content

detect: guard rate filter callback registration against NULL engine - #15558

Closed
kenifor wants to merge 2 commits into
OISF:mainfrom
kenifor:fix-rate-filter-callback-v2
Closed

detect: guard rate filter callback registration against NULL engine#15558
kenifor wants to merge 2 commits into
OISF:mainfrom
kenifor:fix-rate-filter-callback-v2

Conversation

@kenifor

@kenifor kenifor commented Jun 4, 2026

Copy link
Copy Markdown

Ticket: 8560

Make sure these boxes are checked accordingly before submitting your Pull Request -- thank you.

Contribution style:

Our Contribution agreements:

Changes (if applicable):

Link to ticket: https://redmine.openinfosecfoundation.org/issues/8560

Describe changes:

  • Add NULL guard with SCLogError and early return in SCDetectEngineRegisterRateFilterCallback() when DetectEngineGetCurrent() returns NULL. Return type remains void.
  • Update both bundled library examples to check DetectEngineEnabled() before calling the registration function, and log a SCLogWarning when detection is disabled.

Flagged by Svace static analyzer and confirmed by gcc -fanalyzer. Supersedes #15553.

SV_REPO=
SV_BRANCH=
SU_REPO=
SU_BRANCH=

Denis Balashov added 2 commits June 4, 2026 15:49
SCDetectEngineRegisterRateFilterCallback() calls DetectEngineGetCurrent()
and dereferences the result unconditionally. DetectEngineGetCurrent() can
return NULL when a plugin calls this API before the detect engine is
initialized — the bundled library examples do exactly this.

Add a NULL guard with SCLogError and an early return.

Flagged by Svace static analyzer and confirmed by gcc -fanalyzer.

Ticket: 8560
…abled

Wrap SCDetectEngineRegisterRateFilterCallback() in both bundled library
examples with a DetectEngineEnabled() check so it is only called when
detection is active. Log a warning if detection is disabled so the
omission is visible to developers.
Comment thread src/detect-engine.c
@@ -5206,6 +5206,10 @@ void DetectLowerSetupCallback(
void SCDetectEngineRegisterRateFilterCallback(SCDetectRateFilterFunc fn, void *arg)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is right to have a bool return value, but the examples should use it and warn as commented in #15380 (comment)

@catenacyber

Copy link
Copy Markdown
Contributor

confirmed by gcc -fanalyzer

Does this tool find other things ?
Could it be run in CI ?

@victorjulien

Copy link
Copy Markdown
Member

confirmed by gcc -fanalyzer

Does this tool find other things ? Could it be run in CI ?

Like #15559 ?

@victorjulien

Copy link
Copy Markdown
Member

continues in #15586

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants