detect: guard rate filter callback registration against NULL engine - #15558
Closed
kenifor wants to merge 2 commits into
Closed
detect: guard rate filter callback registration against NULL engine#15558kenifor wants to merge 2 commits into
kenifor wants to merge 2 commits into
Conversation
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.
catenacyber
reviewed
Jun 4, 2026
| @@ -5206,6 +5206,10 @@ void DetectLowerSetupCallback( | |||
| void SCDetectEngineRegisterRateFilterCallback(SCDetectRateFilterFunc fn, void *arg) | |||
Contributor
There was a problem hiding this comment.
I think it is right to have a bool return value, but the examples should use it and warn as commented in #15380 (comment)
Contributor
Does this tool find other things ? |
Member
Like #15559 ? |
Closed
Member
|
continues in #15586 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket: 8560
Make sure these boxes are checked accordingly before submitting your Pull Request -- thank you.
Contribution style:
https://docs.suricata.io/en/latest/devguide/contributing/contribution-process.html
Our Contribution agreements:
https://suricata.io/about/contribution-agreement/ (note: this is only required once)
Changes (if applicable):
(including schema descriptions)
https://redmine.openinfosecfoundation.org/projects/suricata/issues
Link to ticket: https://redmine.openinfosecfoundation.org/issues/8560
Describe changes:
SCLogErrorand early return inSCDetectEngineRegisterRateFilterCallback()whenDetectEngineGetCurrent()returns NULL. Return type remainsvoid.DetectEngineEnabled()before calling the registration function, and log aSCLogWarningwhen detection is disabled.Flagged by Svace static analyzer and confirmed by
gcc -fanalyzer. Supersedes #15553.SV_REPO=
SV_BRANCH=
SU_REPO=
SU_BRANCH=