From: Mike Stepanek (mstepane) Date: Mon, 23 Sep 2019 17:36:18 +0000 (-0400) Subject: Merge pull request #1749 in SNORT/snort3 from ~SMINUT/snort3:ips_reload to master X-Git-Tag: 3.0.0-262~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f94ed88102ca496d25d4105da29122dc57c98455;p=thirdparty%2Fsnort3.git Merge pull request #1749 in SNORT/snort3 from ~SMINUT/snort3:ips_reload to master Squashed commit of the following: commit 97392e8fcbcb1397b8c5838f557574da8472cec0 Author: Silviu Minut 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. --- diff --git a/src/managers/module_manager.cc b/src/managers/module_manager.cc index cffc586c3..99f14682e 100644 --- a/src/managers/module_manager.cc +++ b/src/managers/module_manager.cc @@ -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(); } } -