From b1e7917d4fc1f5bcb56c7b31461514a62dfb6042 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Wed, 30 Oct 2024 10:05:14 -0600 Subject: [PATCH] eve: threadinit/deinit callbacks are optional for filetypes 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 | 8 +++++--- src/util-logopenfile.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/output-json.c b/src/output-json.c index c55875a6758f..1f411cc110b8 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -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; } diff --git a/src/util-logopenfile.c b/src/util-logopenfile.c index 2fdbc33c99a0..24063e10954b 100644 --- a/src/util-logopenfile.c +++ b/src/util-logopenfile.c @@ -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); }