The upper range of IDs (base + n_ids) should not exceed max uint32.
In that case ovs_assert is called.

Signed-off-by: Aleksandr Smirnov <[email protected]>
---
v2 : Change reaction from n_ids reduce to ovs_assert()
---
 lib/id-pool.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/id-pool.c b/lib/id-pool.c
index 69910ad08..6fd663f5a 100644
--- a/lib/id-pool.c
+++ b/lib/id-pool.c
@@ -60,6 +60,8 @@ id_pool_destroy(struct id_pool *pool)
 static void
 id_pool_init(struct id_pool *pool, uint32_t base, uint32_t n_ids)
 {
+    ovs_assert(base <= UINT32_MAX - n_ids);
+
     pool->base = base;
     pool->n_ids = n_ids;
     pool->next_free_id = base;
-- 
2.49.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to