Skip to content

Commit b2855a3

Browse files
committed
ndpi: don't access flow storage directly
Remove the check for Flow.storage being NULL. With flex arrays, as long as the flow is allocation, .storage will never be NULL. Prevents NDPI from access this flow field to be less sensitive to ABI changes with respect to data structure sizes.
1 parent 6160165 commit b2855a3

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

plugins/ndpi/ndpi.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,11 @@ static inline struct NdpiThreadContext *NdpiGetThreadContext(ThreadVars *tv)
7171

7272
/**
7373
* Safe helper to get nDPI flow context. Returns NULL if the flow
74-
* or its storage is not available. Guards against the case where
75-
* f->storage is NULL (uninitialized flow) which would crash inside
76-
* SCStorageGetById.
74+
* context is not available.
7775
*/
7876
static inline struct NdpiFlowContext *NdpiGetFlowContext(const Flow *f)
7977
{
80-
if (unlikely(f == NULL || flow_storage_id.id < 0 || f->storage == NULL))
78+
if (unlikely(f == NULL || flow_storage_id.id < 0))
8179
return NULL;
8280
return SCFlowGetStorageById(f, flow_storage_id);
8381
}
@@ -108,11 +106,6 @@ static void OnFlowInit(ThreadVars *tv, Flow *f, const Packet *p, void *_data)
108106
if (unlikely(f == NULL))
109107
return;
110108

111-
if (unlikely(f->storage == NULL)) {
112-
SCLogDebug("Flow %p has no storage, skipping nDPI init", f);
113-
return;
114-
}
115-
116109
struct NdpiFlowContext *flowctx = SCCalloc(1, sizeof(*flowctx));
117110
if (flowctx == NULL) {
118111
SCLogDebug("Failed to allocate nDPI flow context");

0 commit comments

Comments
 (0)