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.
pull/12117/head
Jason Ish 2 years ago committed by Victor Julien
parent 83b1e40028
commit 2ac16ee1a6

@ -439,7 +439,7 @@ void SigTableCleanup(void)
} }
} }
void SigTableSetup(void) void SigTableInit(void)
{ {
if (sigmatch_table == NULL) { if (sigmatch_table == NULL) {
DETECT_TBLSIZE = DETECT_TBLSIZE_STATIC + DETECT_TBLSIZE_STEP; DETECT_TBLSIZE = DETECT_TBLSIZE_STATIC + DETECT_TBLSIZE_STEP;
@ -447,10 +447,12 @@ void SigTableSetup(void)
if (sigmatch_table == NULL) { if (sigmatch_table == NULL) {
DETECT_TBLSIZE = 0; DETECT_TBLSIZE = 0;
FatalError("Could not allocate sigmatch_table"); FatalError("Could not allocate sigmatch_table");
return;
} }
} }
}
void SigTableSetup(void)
{
DetectSidRegister(); DetectSidRegister();
DetectPriorityRegister(); DetectPriorityRegister();
DetectPrefilterRegister(); DetectPrefilterRegister();

@ -338,6 +338,7 @@ extern int DETECT_TBLSIZE_IDX;
#define DETECT_TBLSIZE_STEP 256 #define DETECT_TBLSIZE_STEP 256
int SigTableList(const char *keyword); int SigTableList(const char *keyword);
void SigTableCleanup(void); void SigTableCleanup(void);
void SigTableInit(void);
void SigTableSetup(void); void SigTableSetup(void);
void SigTableRegisterTests(void); void SigTableRegisterTests(void);

@ -240,6 +240,7 @@ void RunUnittests(int list_unittests, const char *regex_arg)
AppLayerSetup(); AppLayerSetup();
/* hardcoded initialization code */ /* hardcoded initialization code */
SigTableInit();
SigTableSetup(); /* load the rule keywords */ SigTableSetup(); /* load the rule keywords */
TmqhSetup(); TmqhSetup();

@ -2670,6 +2670,8 @@ int PostConfLoadedSetup(SCInstance *suri)
MacSetRegisterFlowStorage(); MacSetRegisterFlowStorage();
SigTableInit();
#ifdef HAVE_PLUGINS #ifdef HAVE_PLUGINS
SCPluginsLoad(suri->capture_plugin_name, suri->capture_plugin_args); SCPluginsLoad(suri->capture_plugin_name, suri->capture_plugin_args);
#endif #endif

@ -27,6 +27,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
MpmTableSetup(); MpmTableSetup();
SpmTableSetup(); SpmTableSetup();
EngineModeSetIDS(); EngineModeSetIDS();
SigTableInit();
SigTableSetup(); SigTableSetup();
} }
if (cnt++ == 1024) { if (cnt++ == 1024) {

Loading…
Cancel
Save