From: Mike Stepanek (mstepane) Date: Thu, 23 Jun 2022 12:37:40 +0000 (+0000) Subject: Pull request #3472: Fix port var not reduced bug X-Git-Tag: 3.1.33.0~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=deecfb7e2827dd02186761ee18f64fd5d948dfe4;p=thirdparty%2Fsnort3.git Pull request #3472: Fix port var not reduced bug Merge in SNORT/snort3 from ~VHORBAN/snort3:fix_port_var_not_reduse_bug to master Squashed commit of the following: commit 73eb4880d0b83dffecf31053d1972c3e656ed42a Author: Volodymyr Horban Date: Tue Jun 14 23:25:11 2022 +0300 parser: update do_hash() function to work correctly with port variables --- diff --git a/src/parser/parse_rule.cc b/src/parser/parse_rule.cc index f648f57fb..bce02f307 100644 --- a/src/parser/parse_rule.cc +++ b/src/parser/parse_rule.cc @@ -420,16 +420,14 @@ bool same_headers(RuleTreeNode* rule, RuleTreeNode* rtn) if ( rule->dip and rtn->dip and sfvar_compare(rule->dip, rtn->dip) != SFIP_EQUAL ) return false; - /* compare the port group pointers - this prevents confusing src/dst port objects - * with the same port set, and it's quicker. It does assume that we only have - * one port object and pointer for each unique port set...this is handled by the - * parsing and initial port object storage and lookup. This must be consistent during - * the rule parsing phase. - man */ - if ( (rule->src_portobject != rtn->src_portobject) - or (rule->dst_portobject != rtn->dst_portobject)) - { + if ( rule->src_portobject and rtn->src_portobject + and !PortObjectEqual(rule->src_portobject, rtn->src_portobject) ) return false; - } + + if ( rule->dst_portobject and rtn->dst_portobject + and !PortObjectEqual(rule->dst_portobject, rtn->dst_portobject) ) + return false; + return true; } diff --git a/src/parser/parser.cc b/src/parser/parser.cc index 0ae4e5899..9298f0b05 100644 --- a/src/parser/parser.cc +++ b/src/parser/parser.cc @@ -88,9 +88,7 @@ public: mix(a,b,c); - a += (uint32_t)(uintptr_t)rtn->src_portobject; - b += (uint32_t)(uintptr_t)rtn->dst_portobject; - c += (uint32_t)(uintptr_t)rtnk->policyId; + a += (uint32_t)(uintptr_t)rtnk->policyId; finalize(a,b,c);