]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
frames: use dynamic number of app-layer protos
authorPhilippe Antoine <pantoine@oisf.net>
Mon, 2 Sep 2024 08:47:07 +0000 (10:47 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 8 Jan 2025 16:06:13 +0000 (17:06 +0100)
Ticket: 5053

src/app-layer-frames.c
src/app-layer-frames.h
src/app-layer.c
src/suricata.c

index 432bd020d2305e898352c2f5664e040f5c7d610b..3fa4c345474ada1363b33300f32a62946bfc087a 100644 (file)
 struct FrameConfig {
     SC_ATOMIC_DECLARE(uint64_t, types);
 };
-static struct FrameConfig frame_config[ALPROTO_MAX];
+/* This array should be allocated to contain ALPROTO_MAX protocols. */
+static struct FrameConfig *frame_config;
 
 void FrameConfigInit(void)
 {
+    frame_config = SCCalloc(ALPROTO_MAX, sizeof(struct FrameConfig));
+    if (unlikely(frame_config == NULL)) {
+        FatalError("Unable to alloc frame_config.");
+    }
     for (AppProto p = 0; p < ALPROTO_MAX; p++) {
         SC_ATOMIC_INIT(frame_config[p].types);
     }
 }
 
+void FrameConfigDeInit(void)
+{
+    SCFree(frame_config);
+}
+
 void FrameConfigEnableAll(void)
 {
     const uint64_t bits = UINT64_MAX;
index f49bead57b41ae9fd0f2f53b34820c2be800b5bf..f1d5135d8953fca8018a50857f140dfcc8261118 100644 (file)
@@ -106,6 +106,7 @@ FramesContainer *AppLayerFramesGetContainer(Flow *f);
 FramesContainer *AppLayerFramesSetupContainer(Flow *f);
 
 void FrameConfigInit(void);
+void FrameConfigDeInit(void);
 void FrameConfigEnableAll(void);
 void FrameConfigEnable(const AppProto p, const uint8_t type);
 
index 5c910d0bc98561ffed735f48cdc63b76c0ba6ff6..da69fbe4bad2cca9b8b453004420f562df40a890 100644 (file)
@@ -1041,6 +1041,7 @@ int AppLayerSetup(void)
     AppLayerProtoDetectPrepareState();
 
     AppLayerSetupCounters();
+    FrameConfigInit();
 
     SCReturnInt(0);
 }
@@ -1053,6 +1054,7 @@ int AppLayerDeSetup(void)
     AppLayerParserDeSetup();
 
     AppLayerDeSetupCounters();
+    FrameConfigDeInit();
 
     SCReturnInt(0);
 }
index ee9dfc0b5b694f8428732ac6a3c9532d4fa41b01..6a01b55dd3cae858b40e2f9103e4688b6b67e613 100644 (file)
@@ -361,7 +361,6 @@ void GlobalsInitPreConfig(void)
     SupportFastPatternForSigMatchTypes();
     SCThresholdConfGlobalInit();
     SCProtoNameInit();
-    FrameConfigInit();
 }
 
 void GlobalsDestroy(void)