diff --git a/CHANGES b/CHANGES index 6e206f1761..7e0e389f40 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +3.3.0-dev.596 | 2020-12-03 09:35:42 -0700 + + * Fix a couple of life-time issues when plugin loading fails. + + Reported by Coverity. + + Follow-up to #1179. (Robin Sommer, Corelight) 3.3.0-dev.593 | 2020-12-02 12:53:04 -0800 diff --git a/VERSION b/VERSION index e1b3dfaacc..6edf701c0e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.3.0-dev.593 +3.3.0-dev.596 diff --git a/src/plugin/Manager.cc b/src/plugin/Manager.cc index 614e100ca1..731c9d9a1c 100644 --- a/src/plugin/Manager.cc +++ b/src/plugin/Manager.cc @@ -142,6 +142,8 @@ void Manager::SearchDynamicPlugins(const std::string& dir) bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_not_found, std::vector* errors) { + errors->clear(); // caller should pass it in empty, but just to be sure + dynamic_plugin_map::iterator m = dynamic_plugins.find(util::strtolower(name)); if ( m == dynamic_plugins.end() ) @@ -193,17 +195,19 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_ current_dir = dir.c_str(); current_sopath = path; void* hdl = dlopen(path, RTLD_NOW | RTLD_GLOBAL); + current_dir = nullptr; + current_sopath = nullptr; if ( ! hdl ) { const char* err = dlerror(); errors->push_back(util::fmt("cannot load plugin library %s: %s", path, err ? err : "")); - return false; + continue; } if ( ! current_plugin ) { errors->push_back(util::fmt("load plugin library %s did not instantiate a plugin", path)); - return false; + continue; } current_plugin->SetDynamic(true); @@ -223,17 +227,17 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_ if ( util::strtolower(current_plugin->Name()) != util::strtolower(name) ) { errors->push_back(util::fmt("inconsistent plugin name: %s vs %s", current_plugin->Name().c_str(), name.c_str())); - return false; + continue; } - current_dir = nullptr; - current_sopath = nullptr; current_plugin = nullptr; - DBG_LOG(DBG_PLUGINS, " Loaded %s", path); } globfree(&gl); + + if ( ! errors->empty() ) + return false; } else