Skip to content

Commit

Permalink
eve: threadinit/deinit callbacks are optional for filetypes
Browse files Browse the repository at this point in the history
Only call ThreadInit and ThreadDeinit for custom eve filetypes if they
exist. They are not required by all filetypes.

Ticket: #7359
  • Loading branch information
jasonish authored and victorjulien committed Nov 1, 2024
1 parent 292c218 commit b1e7917
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/output-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/util-logopenfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit b1e7917

Please sign in to comment.