]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1190 in SNORT/snort3 from ftp_config_crash1 to master
authorHui Cao (huica) <huica@cisco.com>
Fri, 20 Apr 2018 15:16:53 +0000 (11:16 -0400)
committerHui Cao (huica) <huica@cisco.com>
Fri, 20 Apr 2018 15:16:53 +0000 (11:16 -0400)
Squashed commit of the following:

commit f57b799a15eaad14dc512edc17cbb5da2a062209
Author: Steve Chew <stechew@cisco.com>
Date:   Fri Apr 13 15:17:54 2018 -0400

    Removed #if 0 and cleaned up string.

commit cddc9d3760a7ac4ddfdccc44a5a8fb76121ed929
Author: Steve Chew <stechew@cisco.com>
Date:   Fri Apr 13 14:10:33 2018 -0400

    FtpServer: ftp_server requires that ftp_client and ftp_data be configured.

src/service_inspectors/ftp_telnet/ft_main.cc
src/service_inspectors/ftp_telnet/ft_main.h
src/service_inspectors/ftp_telnet/ftp.cc
src/service_inspectors/ftp_telnet/ftp_data.cc
src/service_inspectors/ftp_telnet/ftp_module.cc
src/service_inspectors/ftp_telnet/ftp_print.cc

index 70aa12581d71ac812a00b7161040a30873066933..709b6b0bfaf74708428a1bf72e8867a18658b48d 100644 (file)
@@ -47,6 +47,7 @@
 #include "detection/detection_engine.h"
 #include "framework/data_bus.h"
 #include "log/messages.h"
+#include "managers/inspector_manager.h"
 #include "utils/util.h"
 
 #include "ftp_cmd_lookup.h"
@@ -166,17 +167,24 @@ int FTPCheckConfigs(snort::SnortConfig* sc, void* pData)
             "default client and default server configurations.\n");
         return -1;
     }
-#if 0
-    if ( file_api->get_max_file_depth() < 0 )
-    {
-        // FIXIT-M need to change to IT_SERVICE and FTPTelnetChecks
-        // for optimization
-    }
-#endif
+
     int rval;
     if ((rval = CheckFTPServerConfigs(sc, config)))
         return rval;
 
+    //  Verify that FTP client and FTP data inspectors are initialized.
+    if(!snort::InspectorManager::get_inspector(FTP_CLIENT_NAME, false))
+    {
+        ParseError("ftp_server requires that %s also be configured.", FTP_CLIENT_NAME);
+        return -1;
+    }
+
+    if(!snort::InspectorManager::get_inspector(FTP_DATA_NAME, false))
+    {
+        ParseError("ftp_server requires that %s also be configured.", FTP_DATA_NAME);
+        return -1;
+    }
+
     return 0;
 }
 
index c3539b93bbb79780383b1d2112914ffaa5df2c0f..6bb0a0c47b58c60b652222e681eb7073514e70c1 100644 (file)
@@ -44,6 +44,10 @@ struct Packet;
 struct SnortConfig;
 }
 
+#define FTP_CLIENT_NAME "ftp_client"
+#define FTP_DATA_NAME "ftp_data"
+#define FTP_SERVER_NAME "ftp_server"
+
 extern SnortProtocolId ftp_data_snort_protocol_id;
 
 void do_detection(snort::Packet*);
index 9a3b7c89e0925cdb222cfbbfff01c12a7d3b2bc2..1f5e9793905fd929ced49ecc3fc8b37e1954534e 100644 (file)
@@ -45,9 +45,6 @@ using namespace snort;
 
 SnortProtocolId ftp_data_snort_protocol_id = UNKNOWN_PROTOCOL_ID;
 
-#define client_key "ftp_client"
-#define server_key "ftp_server"
-
 #define client_help "FTP inspector client module"
 #define server_help "FTP inspector server module"
 
@@ -359,7 +356,7 @@ FTP_CLIENT_PROTO_CONF* get_ftp_client(Packet* p)
     FtpClient* client = (FtpClient*)p->flow->data;
     if ( !client )
     {
-        client = (FtpClient*)InspectorManager::get_inspector(client_key);
+        client = (FtpClient*)InspectorManager::get_inspector(FTP_CLIENT_NAME);
         assert(client);
         p->flow->set_data(client);
     }
@@ -413,7 +410,7 @@ static const InspectApi fc_api =
         0,
         API_RESERVED,
         API_OPTIONS,
-        client_key,
+        FTP_CLIENT_NAME,
         client_help,
         fc_mod_ctor,
         mod_dtor
@@ -468,7 +465,7 @@ static const InspectApi fs_api =
         0,
         API_RESERVED,
         API_OPTIONS,
-        server_key,
+        FTP_SERVER_NAME,
         server_help,
         fs_mod_ctor,
         mod_dtor
index 1b38df0d7b1ee58218933695053271a2579a7e9b..a631f38ba4b72435ae887493b2ae28e2de89426a 100644 (file)
 #include "stream/stream.h"
 #include "utils/util.h"
 
+#include "ft_main.h"
 #include "ftp_module.h"
 #include "ftpp_si.h"
 #include "ftpdata_splitter.h"
 
 using namespace snort;
 
-#define s_name "ftp_data"
-
 #define s_help \
     "FTP data channel handler"
 
@@ -238,7 +237,7 @@ public:
 class FtpDataModule : public Module
 {
 public:
-    FtpDataModule() : Module(s_name, s_help) { }
+    FtpDataModule() : Module(FTP_DATA_NAME, s_help) { }
 
     const PegInfo* get_pegs() const override;
     PegCount* get_counts() const override;
@@ -314,7 +313,7 @@ const InspectApi fd_api =
         0,
         API_RESERVED,
         API_OPTIONS,
-        s_name,
+        FTP_DATA_NAME,
         s_help,
         mod_ctor,
         mod_dtor
index ca16eb9e404381d02a0da4cf703d83c5d2d2009b..7cfde5685ca1fbc21cdaceb6abfa820fe8f9f864 100644 (file)
 
 #include "log/messages.h"
 
+#include "ft_main.h"
 #include "ftpp_si.h"
 
 using namespace snort;
 using namespace std;
 
-#define FTP_CLIENT "ftp_client"
-#define FTP_SERVER "ftp_server"
-
 #define ftp_client_help \
     "FTP client configuration module for use with ftp_server"
 
@@ -80,7 +78,7 @@ static const Parameter ftp_client_params[] =
 };
 
 FtpClientModule::FtpClientModule() :
-    Module(FTP_CLIENT, ftp_client_help, ftp_client_params)
+    Module(FTP_CLIENT_NAME, ftp_client_help, ftp_client_params)
 {
     conf = nullptr;
 }
@@ -350,7 +348,7 @@ static const PegInfo ftp_pegs[] =
 //-------------------------------------------------------------------------
 
 FtpServerModule::FtpServerModule() :
-    Module(FTP_SERVER, ftp_server_help, ftp_server_params)
+    Module(FTP_SERVER_NAME, ftp_server_help, ftp_server_params)
 {
     conf = nullptr;
 }
index fe1b7c28ffd640ce818b973c4a22c515a3dd11a5..4d2fd71c3e61f6bb7b3f3e112019dc771e4ac954 100644 (file)
@@ -178,7 +178,7 @@ int PrintFTPClientConf(FTP_CLIENT_PROTO_CONF* ClientConf)
     FTP_BOUNCE_TO* FTPBounce;
     int iErr;
 
-    LogMessage("ftp_client:\n");
+    LogMessage(FTP_CLIENT_NAME ":\n");
 
     PrintConfOpt(ClientConf->bounce, "Check for Bounce Attacks");
     PrintConfOpt(ClientConf->telnet_cmds, "Check for Telnet Cmds");
@@ -235,7 +235,7 @@ int PrintFTPServerConf(FTP_SERVER_PROTO_CONF* ServerConf)
         return FTPP_INVALID_ARG;
     }
 
-    LogMessage("ftp_server:\n");
+    LogMessage(FTP_SERVER_NAME ":\n");
 
     PrintConfOpt(ServerConf->telnet_cmds, "Check for Telnet Cmds");
     PrintConfOpt(ServerConf->ignore_telnet_erase_cmds, "Ignore Telnet Cmd Operations");