From: Jason Ish Date: Thu, 17 Oct 2024 19:16:38 +0000 (-0600) Subject: detect: break apart sigtable setup and initialization X-Git-Tag: suricata-8.0.0-beta1~707 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ac16ee1a6cf4b5c2dbcd8e6ab970e0bd8085860;p=thirdparty%2Fsuricata.git detect: break apart sigtable setup and initialization Allows initialization to be done early, so the table is ready for dynamic registration by plugins which are loaded before signature setup. --- diff --git a/src/detect-engine-register.c b/src/detect-engine-register.c index 37fbc98d85..903cc158cf 100644 --- a/src/detect-engine-register.c +++ b/src/detect-engine-register.c @@ -439,7 +439,7 @@ void SigTableCleanup(void) } } -void SigTableSetup(void) +void SigTableInit(void) { if (sigmatch_table == NULL) { DETECT_TBLSIZE = DETECT_TBLSIZE_STATIC + DETECT_TBLSIZE_STEP; @@ -447,10 +447,12 @@ void SigTableSetup(void) if (sigmatch_table == NULL) { DETECT_TBLSIZE = 0; FatalError("Could not allocate sigmatch_table"); - return; } } +} +void SigTableSetup(void) +{ DetectSidRegister(); DetectPriorityRegister(); DetectPrefilterRegister(); diff --git a/src/detect-engine-register.h b/src/detect-engine-register.h index c9134c77b8..db4cd957af 100644 --- a/src/detect-engine-register.h +++ b/src/detect-engine-register.h @@ -338,6 +338,7 @@ extern int DETECT_TBLSIZE_IDX; #define DETECT_TBLSIZE_STEP 256 int SigTableList(const char *keyword); void SigTableCleanup(void); +void SigTableInit(void); void SigTableSetup(void); void SigTableRegisterTests(void); diff --git a/src/runmode-unittests.c b/src/runmode-unittests.c index e116e86d5b..35780ab101 100644 --- a/src/runmode-unittests.c +++ b/src/runmode-unittests.c @@ -240,6 +240,7 @@ void RunUnittests(int list_unittests, const char *regex_arg) AppLayerSetup(); /* hardcoded initialization code */ + SigTableInit(); SigTableSetup(); /* load the rule keywords */ TmqhSetup(); diff --git a/src/suricata.c b/src/suricata.c index 6bdd6edb90..ee9dfc0b5b 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -2670,6 +2670,8 @@ int PostConfLoadedSetup(SCInstance *suri) MacSetRegisterFlowStorage(); + SigTableInit(); + #ifdef HAVE_PLUGINS SCPluginsLoad(suri->capture_plugin_name, suri->capture_plugin_args); #endif diff --git a/src/tests/fuzz/fuzz_siginit.c b/src/tests/fuzz/fuzz_siginit.c index a98148cfac..a50e1fd67e 100644 --- a/src/tests/fuzz/fuzz_siginit.c +++ b/src/tests/fuzz/fuzz_siginit.c @@ -27,6 +27,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) MpmTableSetup(); SpmTableSetup(); EngineModeSetIDS(); + SigTableInit(); SigTableSetup(); } if (cnt++ == 1024) {