From 9b11fefe2844e3f574bfa0bb720922f588420882 Mon Sep 17 00:00:00 2001 From: Shivani Bhardwaj Date: Tue, 20 Feb 2024 21:53:14 +0530 Subject: [PATCH] detect/port: remove the port cut/insertion stage As this is already taken care of and a list of ports is available for use by the next stage. Ticket 6792 Bug 6414 (cherry picked from commit 83aba93f40b0c12b5336f1f5281ae33b726f57ea) --- src/detect-engine-build.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/detect-engine-build.c b/src/detect-engine-build.c index a23a29e205..e8ca516ec2 100644 --- a/src/detect-engine-build.c +++ b/src/detect-engine-build.c @@ -1382,6 +1382,9 @@ static DetectPort *RulesGroupByPorts(DetectEngineCtx *de_ctx, uint8_t ipproto, u s = s->next; } + /* step 2: create a list of the smallest port ranges with + * appropriate SGHs */ + /* Create an interval tree of all the given ports to make the search * for overlaps later on easier */ SCPortIntervalTree *it = SCPortIntervalTreeInit(); @@ -1398,17 +1401,6 @@ static DetectPort *RulesGroupByPorts(DetectEngineCtx *de_ctx, uint8_t ipproto, u } } - /* step 2: create a list of DetectPort objects */ - for (htb = HashListTableGetListHead(de_ctx->dport_hash_table); - htb != NULL; - htb = HashListTableGetListNext(htb)) - { - DetectPort *p = HashListTableGetListData(htb); - DetectPort *tmp = DetectPortCopySingle(de_ctx, p); - BUG_ON(tmp == NULL); - int r = DetectPortInsert(de_ctx, &list , tmp); - BUG_ON(r == -1); - } /* Create a sorted list of ports in ascending order after resolving overlaps * and corresponding SGHs */ if (CreatePortList(de_ctx, unique_port_points, size_unique_port_arr, it, &list) < 0) -- 2.47.2