mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/topic/robin/gh-1179-plugin-loading-fixes'
* origin/topic/robin/gh-1179-plugin-loading-fixes: Fix a couple of life-time issues when plugin loading fails.
This commit is contained in:
commit
c643ed2fe4
3 changed files with 18 additions and 7 deletions
7
CHANGES
7
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
|
||||
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
3.3.0-dev.593
|
||||
3.3.0-dev.596
|
||||
|
|
|
@ -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<std::string>* 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 : "<unknown error>"));
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue