]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1376 in SNORT/snort3 from reload_failed_smtp to master
authorTom Peters (thopeter) <thopeter@cisco.com>
Mon, 8 Oct 2018 21:49:56 +0000 (17:49 -0400)
committerTom Peters (thopeter) <thopeter@cisco.com>
Mon, 8 Oct 2018 21:49:56 +0000 (17:49 -0400)
Squashed commit of the following:

commit 2b102d510abec6dee33d07243a35ca5076223f9e
Author: Steven Baigal (sbaigal) <sbaigal@cisco.com>
Date:   Wed Sep 26 12:54:15 2018 -0400

    reload: fixed smtp seg fault when reload failed

src/service_inspectors/smtp/smtp.cc
src/service_inspectors/smtp/smtp_config.h

index 320ee4bb14a99ffe421b11b2bbb115a3354fc6b2..376d53ef07e147dfaa89e89a828a5f41a32ecc70 100644 (file)
@@ -245,11 +245,16 @@ static void SMTP_InitCmds(SMTP_PROTO_CONF* config)
 
 static void SMTP_TermCmds(SMTP_PROTO_CONF* config)
 {
-    for ( int i = 0; i <= config->num_cmds; ++i )
-        snort_free(const_cast<char*>(config->cmds[i].name));
-
-    snort_free(config->cmds);
-    snort_free(config->cmd_config);
+    if (!config)
+        return;
+    if (config->cmds)
+    {
+        for ( int i = 0; i <= config->num_cmds; ++i )
+            snort_free(const_cast<char*>(config->cmds[i].name));
+        snort_free(config->cmds);
+    }
+    if (config->cmd_config)
+        snort_free(config->cmd_config);
 }
 
 static void SMTP_CommandSearchInit(SMTP_PROTO_CONF* config)
@@ -269,6 +274,8 @@ static void SMTP_CommandSearchInit(SMTP_PROTO_CONF* config)
 
 static void SMTP_CommandSearchTerm(SMTP_PROTO_CONF* config)
 {
+    if (config->cmd_search == nullptr)
+        return;
     snort_free(config->cmd_search);
     delete config->cmd_search_mpse;
 }
index b579553a2f3fcf40dbe8f61d35b86fb95630bc87..3546a72a69ccb3dcd49424cf14725f2b94895e6e 100644 (file)
@@ -138,10 +138,10 @@ struct SMTP_PROTO_CONF
     uint32_t xtra_ehdrs_id;
 
     int num_cmds;
-    SMTPToken* cmds;
-    SMTPCmdConfig* cmd_config;
-    SMTPSearch* cmd_search;
-    snort::SearchTool* cmd_search_mpse;
+    SMTPToken* cmds = nullptr;
+    SMTPCmdConfig* cmd_config = nullptr;
+    SMTPSearch* cmd_search = nullptr;
+    snort::SearchTool* cmd_search_mpse = nullptr;
 };
 
 struct SmtpStats