From f739a8a73cbbd14979d13b888e6088c76c26867c Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Wed, 3 Jun 2026 12:31:07 -0600 Subject: [PATCH] ndpi: don't access flow storage directly Remove the check for Flow.storage being NULL. With flex arrays, as long as the flow is allocated, .storage will never be NULL. We do make sure the flow is not NULL, and the storage functions are safe to the storage being NULL. Prevents NDPI from accessing this flow field to be less sensitive to ABI changes with respect to data structure sizes. Ticket: #8632 --- plugins/ndpi/ndpi.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/plugins/ndpi/ndpi.c b/plugins/ndpi/ndpi.c index ab7a594362..14960828cf 100644 --- a/plugins/ndpi/ndpi.c +++ b/plugins/ndpi/ndpi.c @@ -71,13 +71,11 @@ static inline struct NdpiThreadContext *NdpiGetThreadContext(ThreadVars *tv) /** * Safe helper to get nDPI flow context. Returns NULL if the flow - * or its storage is not available. Guards against the case where - * f->storage is NULL (uninitialized flow) which would crash inside - * SCStorageGetById. + * context is not available. */ static inline struct NdpiFlowContext *NdpiGetFlowContext(const Flow *f) { - if (unlikely(f == NULL || flow_storage_id.id < 0 || f->storage == NULL)) + if (unlikely(f == NULL || flow_storage_id.id < 0)) return NULL; return SCFlowGetStorageById(f, flow_storage_id); } @@ -108,11 +106,6 @@ static void OnFlowInit(ThreadVars *tv, Flow *f, const Packet *p, void *_data) if (unlikely(f == NULL)) return; - if (unlikely(f->storage == NULL)) { - SCLogDebug("Flow %p has no storage, skipping nDPI init", f); - return; - } - struct NdpiFlowContext *flowctx = SCCalloc(1, sizeof(*flowctx)); if (flowctx == NULL) { SCLogDebug("Failed to allocate nDPI flow context");