]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #3472: Fix port var not reduced bug
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Thu, 23 Jun 2022 12:37:40 +0000 (12:37 +0000)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Thu, 23 Jun 2022 12:37:40 +0000 (12:37 +0000)
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 <vhorban@cisco.com>
Date:   Tue Jun 14 23:25:11 2022 +0300

    parser: update do_hash() function to work correctly with port variables

src/parser/parse_rule.cc
src/parser/parser.cc

index f648f57fb4caadb9a67bc40ad9dc1fb282f913d0..bce02f30733cf8b8814c8899756156209a83b11b 100644 (file)
@@ -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;
 }
 
index 0ae4e5899cbe767ad9e2b931152ad4452f3a255f..9298f0b05e12e878c9a1c844bff851c98ff80a2e 100644 (file)
@@ -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);