From: Jason Ish Date: Wed, 30 Oct 2024 16:05:14 +0000 (-0600) Subject: eve: threadinit/deinit callbacks are optional for filetypes X-Git-Tag: suricata-8.0.0-beta1~747 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1e7917d4fc1f5bcb56c7b31461514a62dfb6042;p=thirdparty%2Fsuricata.git 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 --- diff --git a/src/output-json.c b/src/output-json.c index c55875a675..1f411cc110 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 2fdbc33c99..24063e1095 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); }