From b06ede91561fbac4a7e29e1569d4855c8f3e2d54 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Sat, 5 Oct 2019 13:47:49 +0200 Subject: lib: Add check that flow_id is valid In fset_add, the flow_id was passed to the shm_flow_set without checking if it was actually valid. Signed-off-by: Sander Vrijders Signed-off-by: Dimitri Staessens --- src/lib/dev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/dev.c b/src/lib/dev.c index 1e0a177d..ee7ae4f1 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -1209,6 +1209,11 @@ int fset_add(struct flow_set * set, pthread_rwlock_wrlock(&ai.lock); + if (ai.flows[fd].flow_id < 0) { + pthread_rwlock_unlock(&ai.lock); + return -EINVAL; + } + ret = shm_flow_set_add(ai.fqset, set->idx, ai.flows[fd].flow_id); packets = shm_rbuff_queued(ai.flows[fd].rx_rb); -- cgit v1.2.3