]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
eve: threadinit/deinit callbacks are optional for filetypes 12074/head
authorJason Ish <jason.ish@oisf.net>
Wed, 30 Oct 2024 16:05:14 +0000 (10:05 -0600)
committerVictor Julien <victor@inliniac.net>
Fri, 1 Nov 2024 10:50:43 +0000 (11:50 +0100)
Only call ThreadInit and ThreadDeinit for custom eve filetypes if they
exist. They are not required by all filetypes.

Ticket: #7359

src/output-json.c
src/util-logopenfile.c

index c55875a6758f0ff0381b817b29fd3e40baaab753..1f411cc110b8920fda2f4ef0650b3ec882de2c6d 100644 (file)
@@ -1050,9 +1050,11 @@ static int LogFileTypePrepare(
                     &json_ctx->file_ctx->filetype.init_data) < 0) {
             return -1;
         }
-        if (json_ctx->filetype->ThreadInit(json_ctx->file_ctx->filetype.init_data, 0,
-                    &json_ctx->file_ctx->filetype.thread_data) < 0) {
-            return -1;
+        if (json_ctx->filetype->ThreadInit) {
+            if (json_ctx->filetype->ThreadInit(json_ctx->file_ctx->filetype.init_data, 0,
+                        &json_ctx->file_ctx->filetype.thread_data) < 0) {
+                return -1;
+            }
         }
         json_ctx->file_ctx->filetype.filetype = json_ctx->filetype;
     }
index 2fdbc33c99a09bc696771f7b0e88383a3bea754d..24063e10954bb625bafd76c5dbfee01b71a30619 100644 (file)
@@ -871,7 +871,7 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
         SCReturnInt(0);
     }
 
-    if (lf_ctx->type == LOGFILE_TYPE_FILETYPE) {
+    if (lf_ctx->type == LOGFILE_TYPE_FILETYPE && lf_ctx->filetype.filetype->ThreadDeinit) {
         lf_ctx->filetype.filetype->ThreadDeinit(
                 lf_ctx->filetype.init_data, lf_ctx->filetype.thread_data);
     }