Skip to content

Commit

Permalink
ndpi: check for flow earlier in eve callback
Browse files Browse the repository at this point in the history
The eve callback in ndpi requires a flow, so bail earlier if there is
no flow.
  • Loading branch information
jasonish committed Jan 16, 2025
1 parent ad50851 commit 47eacf3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/ndpi/ndpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,11 @@ static void DetectnDPIRiskFree(DetectEngineCtx *de_ctx, void *ptr)

static void EveCallback(ThreadVars *tv, const Packet *p, Flow *f, JsonBuilder *jb, void *data)
{
/* Adding ndpi info to EVE requires a flow. */
if (f == NULL) {
return;
}

struct NdpiThreadContext *threadctx = ThreadGetStorageById(tv, thread_storage_id);
struct NdpiFlowContext *flowctx = FlowGetStorageById(f, flow_storage_id);
ndpi_serializer serializer;
Expand All @@ -448,9 +453,6 @@ static void EveCallback(ThreadVars *tv, const Packet *p, Flow *f, JsonBuilder *j

SCLogDebug("EveCallback: tv=%p, p=%p, f=%p", tv, p, f);

if (f == NULL)
return;

ndpi_init_serializer(&serializer, ndpi_serialization_format_inner_json);

/* Use ndpi_dpi2json to get a JSON with nDPI metadata */
Expand Down

0 comments on commit 47eacf3

Please sign in to comment.