]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #3667: smtp: Do not accumulate cmds across policies and reloads.
authorSteve Chew (stechew) <stechew@cisco.com>
Tue, 15 Nov 2022 22:54:00 +0000 (22:54 +0000)
committerSteve Chew (stechew) <stechew@cisco.com>
Tue, 15 Nov 2022 22:54:00 +0000 (22:54 +0000)
Merge in SNORT/snort3 from ~STECHEW/snort3:slow_reload_fix to master

Squashed commit of the following:

commit 12055a3409f2373424b8e1c0cd418f654e27bc4d
Author: Steve Chew <stechew@cisco.com>
Date:   Tue Nov 15 13:29:18 2022 -0500

    smtp: Do not accumulate cmds across policies and reloads. Avoids memory and performance problem.

src/service_inspectors/smtp/smtp.cc
src/service_inspectors/smtp/smtp_module.cc
src/service_inspectors/smtp/smtp_module.h

index c118cf8ffa08647efb0e4d89e4ce65c4bc36bf29..22d68086554671063a680834f74cdf827e7197d5 100644 (file)
@@ -1607,6 +1607,8 @@ static Inspector* smtp_ctor(Module* m)
     while ( (cmd = mod->get_cmd(i++)) )
         smtp->ProcessSmtpCmdsList(cmd);
 
+    mod->clear_cmds();
+
     return smtp;
 }
 
index 0e266ffbed9288e115a1071e10954f2ca001c03d..45fd1a0495bc21bccc30184d84da31057096c12e 100644 (file)
@@ -199,8 +199,7 @@ SmtpModule::~SmtpModule()
         delete config;
     }
 
-    for ( auto p : cmds )
-        delete p;
+    clear_cmds();
 }
 
 const RuleMap* SmtpModule::get_rules() const
@@ -233,6 +232,14 @@ const SmtpCmd* SmtpModule::get_cmd(unsigned idx)
         return nullptr;
 }
 
+void SmtpModule::clear_cmds()
+{
+    for ( auto p : cmds )
+        delete p;
+
+    cmds.clear();
+}
+
 bool SmtpModule::set(const char*, Value& v, SnortConfig*)
 {
     if ( v.is("auth_cmds") )
index bf2e62dba6b65c88eeccb75dfc6a7d286db5db13..0b05ff00f9ab8be1b866d486ffdf0434f98880f8 100644 (file)
@@ -96,6 +96,7 @@ public:
 
     SmtpProtoConf* get_data();
     const SmtpCmd* get_cmd(unsigned idx);
+    void clear_cmds();
 
     Usage get_usage() const override
     { return INSPECT; }