[EU-FOSSA] Fix loading unexpected dll as plugin issue

Unexpect behaviour: if "<NppDir>\...dll" and/or "<NppDir>\plugins\..dll" exist, they will be loaded because Notepad++ try to load "<NppDir>\pluginName\pluginName.dll" as plugin, in our case "<NppDir>\plugins\..\...dll" and "<NppDir>\plugins\.\..dll" respectively.

The fix is excluding both directories ".." & "." to not load mentionned above unwanted dll.
This commit is contained in:
Don HO 2019-01-19 03:30:54 +01:00
parent e813f0383b
commit abf78e84b2

View File

@ -318,11 +318,14 @@ bool PluginsManager::loadPluginsV2(const TCHAR* dir)
// get plugin folder
if (hFindFolder != INVALID_HANDLE_VALUE && (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
generic_string foundFileName = foundData.cFileName;
if (foundFileName != TEXT(".") && foundFileName != TEXT(".."))
{
generic_string pluginsFullPathFilter = pluginsFolder;
PathAppend(pluginsFullPathFilter, foundData.cFileName);
PathAppend(pluginsFullPathFilter, foundFileName);
generic_string pluginsFolderPath = pluginsFullPathFilter;
generic_string dllName = foundData.cFileName;
generic_string dllName = foundFileName;
dllName += TEXT(".dll");
PathAppend(pluginsFullPathFilter, dllName);
@ -333,16 +336,19 @@ bool PluginsManager::loadPluginsV2(const TCHAR* dir)
dllNames.push_back(pluginsFullPathFilter);
PluginList & pl = nppParams->getPluginList();
pl.add(foundData.cFileName, false);
pl.add(foundFileName, false);
}
}
// get plugin folder
while (::FindNextFile(hFindFolder, &foundData))
{
generic_string foundFileName2 = foundData.cFileName;
if (foundFileName2 != TEXT(".") && foundFileName2 != TEXT(".."))
{
generic_string pluginsFullPathFilter2 = pluginsFolder;
PathAppend(pluginsFullPathFilter2, foundData.cFileName);
PathAppend(pluginsFullPathFilter2, foundFileName2);
generic_string pluginsFolderPath2 = pluginsFullPathFilter2;
generic_string dllName2 = foundData.cFileName;
generic_string dllName2 = foundFileName2;
dllName2 += TEXT(".dll");
PathAppend(pluginsFullPathFilter2, dllName2);
@ -358,7 +364,8 @@ bool PluginsManager::loadPluginsV2(const TCHAR* dir)
dllNames.push_back(pluginsFullPathFilter2);
PluginList & pl = nppParams->getPluginList();
pl.add(foundData.cFileName, false);
pl.add(foundFileName2, false);
}
}
}