]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4925: appid: SNI and CNAME patterns matching fix
authorChris Sherwin (chsherwi) <chsherwi@cisco.com>
Wed, 5 Nov 2025 12:49:15 +0000 (12:49 +0000)
committerChris Sherwin (chsherwi) <chsherwi@cisco.com>
Wed, 5 Nov 2025 12:49:15 +0000 (12:49 +0000)
Merge in SNORT/snort3 from ~AMILASH/snort3:cname_sni_pattern_matching to master

Squashed commit of the following:

commit 6b2ac4841f641790fce314bb369289009b977907
Author: Artur <amilash@cisco.com>
Date:   Tue Sep 30 08:08:56 2025 -0400

    appid: SNI and CNAME patterns matching fix

src/network_inspectors/appid/detector_plugins/host_patterns.cc

index 5de5d7f64dc0264eecce082c36c6fce9f9a381be..9879703f370e3ef29d10d6152bfe9e49b5d70f7d 100644 (file)
@@ -127,11 +127,10 @@ inline bool host_pattern_validate_url_match(const MatchedHostPatterns * const mp
                 data[mp->match_start_pos-1] == '.';
 }
 
-inline bool is_perfect_literal_match(const MatchedHostPatterns * const mp, const size_t& data_size)
-{
-    return mp->mpattern->is_literal and  mp->match_start_pos == 0 and
-            (mp->match_start_pos + mp->mpattern->pattern_size == data_size);
-
+inline bool is_perfect_literal_match(const MatchedHostPatterns * const mp, const size_t& data_size, const HostPatternType& type)
+{    
+    return mp->mpattern->is_literal and mp->match_start_pos == 0 and
+            mp->mpattern->pattern_size == data_size and mp->mpattern->pattern_type == type;
 }
 
 template<HostPatternType T>
@@ -158,7 +157,7 @@ bool scan_patterns(SearchTool& matcher, const uint8_t* data, size_t size,
         {
             if ( T != HostPatternType::HOST_PATTERN_TYPE_URL)
             {
-                if ( is_perfect_literal_match(tmp, size) )
+                if ( is_perfect_literal_match(tmp, size, T) )
                 {
                     best_match = match;
                     break;