]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1685 in SNORT/snort3 from ~SMINUT/snort3:pcre_peg_counts to master
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Mon, 29 Jul 2019 20:16:30 +0000 (16:16 -0400)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Mon, 29 Jul 2019 20:16:30 +0000 (16:16 -0400)
Squashed commit of the following:

commit 8efc8f5a2de33908a9dd5094f088e06b371e6997
Author: Silviu Minut <sminut@cisco.com>
Date:   Thu Jul 18 09:59:13 2019 -0400

    pcre: add peg counts for PCRE_ERROR_MATCHLIMIT and PCRE_ERROR_RECURSIONLIMIT return status from pcre_exec().

src/ips_options/ips_pcre.cc
src/utils/stats.cc
src/utils/stats.h

index 5737c94effd14fcf3bda2cd854a8eb9771e3dbdc..4a9450c6fdddd7d56aa1a42dbcebd950cdd7b523 100644 (file)
@@ -394,8 +394,19 @@ static bool pcre_search(
     {
         matched = false;
     }
+    else if (result == PCRE_ERROR_MATCHLIMIT)
+    {
+        pc.pcre_match_limit++;
+        matched = false;
+    }
+    else if (result == PCRE_ERROR_RECURSIONLIMIT)
+    {
+        pc.pcre_recursion_limit++;
+        matched = false;
+    }
     else
     {
+        pc.pcre_error++;
         return false;
     }
 
index d4265de1a7307f3adedb76635b4c25d66480956b..5334706633221e5b4ae95166b680a35b47e32669 100644 (file)
@@ -197,6 +197,9 @@ const PegInfo pc_names[] =
     { CountType::SUM, "offload_fallback", "fast pattern offload search fallback attempts" },
     { CountType::SUM, "offload_failures", "fast pattern offload search failures" },
     { CountType::SUM, "offload_suspends", "fast pattern search suspends due to offload context chains" },
+    { CountType::SUM, "pcre_match_limit", "total number of times pcre hit the match limit" },
+    { CountType::SUM, "pcre_recursion_limit", "total number of times pcre hit the recursion limit" },
+    { CountType::SUM, "pcre_error", "total number of times pcre returns error" },
     { CountType::END, nullptr, nullptr }
 };
 
@@ -220,7 +223,7 @@ void DropStats()
 {
     LogLabel("Packet Statistics");
     ModuleManager::get_module("daq")->show_stats();
-    
+
     PacketManager::dump_stats();
 
     LogLabel("Module Statistics");
index 6e24ccaeeb26241b290e785f7f7b23be03ecfe64..9ab6bfb0386699fc3c51c534e8584a7f0962ec84 100644 (file)
@@ -60,6 +60,9 @@ struct PacketCount
     PegCount offload_fallback;
     PegCount offload_failures;
     PegCount offload_suspends;
+    PegCount pcre_match_limit;
+    PegCount pcre_recursion_limit;
+    PegCount pcre_error;
 };
 
 struct ProcessCount
@@ -121,4 +124,3 @@ void TimeStart();
 void TimeStop();
 
 #endif
-