Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DLL-Loader whitelist instead blacklist until sandboxing is an topic #9619

Merged
merged 1 commit into from
Apr 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 5 additions & 28 deletions xbmc/cores/DllLoader/Win32DllLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ void Win32DllLoader::OverrideImports(const std::string &dll)

bool Win32DllLoader::NeedsHooking(const char *dllName)
{
if ( !StringUtils::EndsWithNoCase(dllName, "libdvdcss-2.dll")
&& !StringUtils::EndsWithNoCase(dllName, "libdvdnav.dll"))
return false;

LibraryLoader *loader = DllLoaderContainer::GetModule(dllName);
if (loader)
{
Expand All @@ -334,34 +338,7 @@ bool Win32DllLoader::NeedsHooking(const char *dllName)
return false;
}
}
std::wstring strdllNameW;
g_charsetConverter.utf8ToW(CSpecialProtocol::TranslatePath(dllName), strdllNameW, false);
HMODULE hModule = GetModuleHandleW(strdllNameW.c_str());
if (hModule == NULL)
return false;

wchar_t filepathW[MAX_PATH];
GetModuleFileNameW(hModule, filepathW, MAX_PATH);
std::string dllPath;
g_charsetConverter.wToUTF8(filepathW, dllPath);

// compare this filepath with some special directories
std::string xbmcPath = CSpecialProtocol::TranslatePath("special://xbmc");
std::string homePath = CSpecialProtocol::TranslatePath("special://home");
std::string tempPath = CSpecialProtocol::TranslatePath("special://temp");

//need a better version of this really
//We can ignore modules we know don't need any special file access
if (StringUtils::EndsWithNoCase(dllPath, "libcurl.dll") ||
StringUtils::EndsWithNoCase(dllPath, "libeay32.dll") ||
StringUtils::EndsWithNoCase(dllPath, "ssleay32.dll"))
{
return false;
}

return (StringUtils::StartsWith(dllPath, xbmcPath) ||
StringUtils::StartsWith(dllPath, homePath) ||
StringUtils::StartsWith(dllPath, tempPath));
return true;
}

void Win32DllLoader::RestoreImports()
Expand Down