Bug 1726474 - Preload rlbox library on Windows. r=nika

Differential Revision: https://phabricator.services.mozilla.com/D123039
This commit is contained in:
Mike Hommey 2021-08-24 02:52:18 +00:00
Родитель 3999ffe70d
Коммит 44bb728fba
1 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -27,10 +27,15 @@ PathString GetSandboxedRLBoxPath() {
return libFile->NativePath();
}
PRLibrary* PreloadLibrary(const nsCString& path) {
PRLibrary* PreloadLibrary(const PathString& path) {
PRLibSpec libSpec;
#ifdef XP_WIN
libSpec.type = PR_LibSpec_PathnameU;
libSpec.value.pathname_u = path.get();
#else
libSpec.type = PR_LibSpec_Pathname;
libSpec.value.pathname = path.get();
#endif
PRLibrary* ret = PR_LoadLibraryWithFlags(libSpec, PR_LD_LAZY);
return ret;
}
@ -38,9 +43,8 @@ PRLibrary* PreloadLibrary(const nsCString& path) {
void PreloadSandboxedDynamicLibrary() {
// The process level sandbox does not allow loading of dynamic libraries.
// This preloads wasm sandboxed libraries before the process level sandbox is
// enabled. Currently, this is only needed for Linux as Mac allows loading
// libraries from the package file.
#if defined(XP_LINUX) && defined(MOZ_USING_WASM_SANDBOXING)
// enabled. Currently, this is only needed for Linux and Windows.
#if (defined(XP_LINUX) || defined(XP_WIN)) && defined(MOZ_USING_WASM_SANDBOXING)
if (!PreloadLibrary(GetSandboxedRLBoxPath())) {
MOZ_CRASH("Library preload failure: Failed to load librlbox\n");
}