]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1757 in SNORT/snort3 from ~SMINUT/snort3:reload_module_reputation...
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Tue, 24 Sep 2019 14:20:05 +0000 (10:20 -0400)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Tue, 24 Sep 2019 14:20:05 +0000 (10:20 -0400)
Squashed commit of the following:

commit 7fcf2e12927d6e6511d7d3b03efbbdc2f96ce0a0
Author: Silviu Minut <sminut@cisco.com>
Date:   Mon Sep 23 12:54:40 2019 -0400

    reputation: prevent reload module crash when reputation is not configured in lua at startup.

src/main/snort.cc
src/managers/module_manager.cc
src/network_inspectors/reputation/reputation_inspect.cc
src/network_inspectors/reputation/reputation_module.cc

index d9a4aacafd54fbff6cf5cd2507fdd0f8ce011d65..02397c8ed9c0845d7b3bb4fb47001b50052d67ad 100644 (file)
@@ -508,6 +508,7 @@ SnortConfig* Snort::get_reload_config(const char* fname)
 SnortConfig* Snort::get_updated_policy(SnortConfig* other_conf, const char* fname, const char* iname)
 {
     reloading = true;
+    reset_parse_errors();
 
     SnortConfig* sc = new SnortConfig(other_conf);
 
@@ -565,6 +566,7 @@ SnortConfig* Snort::get_updated_module(SnortConfig* other_conf, const char* name
 
     if ( name )
     {
+        reset_parse_errors();
         ModuleManager::reset_errors();
         ModuleManager::reload_module(name, sc);
         if ( ModuleManager::get_errors() || !sc->verify() )
index 4a29c8942fa2ddd051d6dedea122f999f2fe5cbd..ab718f9aabdb747e7a10a93154e7bd257a4c09ad 100644 (file)
@@ -1058,7 +1058,7 @@ void ModuleManager::reload_module(const char* name, snort::SnortConfig* sc)
     if ( h and h->api and h->mod and sc )
     {
         PluginManager::instantiate(h->api, h->mod, sc);
-
+        s_errors += get_parse_errors();
     }
     else
     {
index b4419a8bf1b480edd5e4e33ad1e997a5a4c43b41..cbc198f0504ec7e6f378d6094aff1ca86a934b68 100644 (file)
@@ -420,7 +420,8 @@ static void reputation_init()
 static Inspector* reputation_ctor(Module* m)
 {
     ReputationModule* mod = (ReputationModule*)m;
-    return new Reputation(mod->get_data());
+    ReputationConfig* conf = mod->get_data();
+    return conf ? new Reputation(conf) : nullptr;
 }
 
 static void reputation_dtor(Inspector* p)
@@ -465,4 +466,3 @@ SO_PUBLIC const BaseApi* snort_plugins[] =
 #else
 const BaseApi* nin_reputation = &reputation_api.base;
 #endif
-
index 6b80e4539432ccc5921aa936221a5ab52ed2832f..655633878339278f6214863aa4a7d92e0fe87239 100644 (file)
@@ -152,6 +152,10 @@ bool ReputationModule::set(const char*, Value& v, SnortConfig*)
 
 ReputationConfig* ReputationModule::get_data()
 {
+
+    // FIXIT-M: this needs to be set to NULL prior to returning here.
+    // If we do that, though, reload module will error out, even when
+    // reputation has been properly configured (on startup) in lua.
     return conf;
 }