]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1749 in SNORT/snort3 from ~SMINUT/snort3:ips_reload to master
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Mon, 23 Sep 2019 17:36:18 +0000 (13:36 -0400)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Mon, 23 Sep 2019 17:36:18 +0000 (13:36 -0400)
Squashed commit of the following:

commit 97392e8fcbcb1397b8c5838f557574da8472cec0
Author: Silviu Minut <sminut@cisco.com>
Date:   Tue Sep 17 16:17:24 2019 -0400

    managers: add null check in reload_module to prevent crash when trying to reload module that has not been configured.

src/managers/module_manager.cc

index cffc586c392a096971f6b2d5b7eba4981ee1cb1e..99f14682e8c24cfdaf6713b47cc8be3bb7b5a288 100644 (file)
@@ -1048,14 +1048,23 @@ void ModuleManager::show_module(const char* name)
 
 void ModuleManager::reload_module(const char* name, snort::SnortConfig* sc)
 {
-    if ( ModHook* h = get_hook(name) )
+    ModHook* h = get_hook(name);
+
+    // FIXIT-L: we can check that h->api is not null here or inside instantiate.
+    // Both alternatives prevent crashing in instantiate(). However,
+    // checking it here might be too aggressive, because we are also saying it
+    // is an error. That makes the caller of this function
+    // (get_updated_module()) discard other legitimate reload operations, e.g.
+    // the newly read configuration. We should decide on this when proper
+    // reload functionality gets implemented.
+    if ( h and h->api and h->mod and sc )
     {
         PluginManager::instantiate(h->api, h->mod, sc);
 
     }
     else
     {
-        cout << "Module " << name <<" doesn't exist";
+        cout << "Module " << name <<" doesn't exist or reload not implemented.";
         cout << endl;
         ++s_errors;
     }
@@ -1454,4 +1463,3 @@ void ModuleManager::reset_stats(SnortConfig*)
         p->mod->reset_stats();
     }
 }
-