зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1445601 - Stop using LoadLibraryA in GMP. r=cpearce
We should not use LoadLibraryA (or more generally "A" functions) on Windows because it is lossy. Bug 1440886 will introduce a static analysis to prevent potential misuse of LoadLibraryA, so we need to replace existing usages first. MozReview-Commit-ID: 6krgrVcSHNW --HG-- extra : rebase_source : 0e93acecfe0c9ccd2e4ba9ad3126b6ae16433387
This commit is contained in:
Родитель
e98b2c42f0
Коммит
d7043295be
|
@ -17,6 +17,7 @@
|
|||
#include "gmp-video-decode.h"
|
||||
#include "gmp-video-encode.h"
|
||||
#include "GMPPlatform.h"
|
||||
#include "mozilla/Algorithm.h"
|
||||
#include "mozilla/ipc/CrashReporterClient.h"
|
||||
#include "mozilla/ipc/ProcessChild.h"
|
||||
#include "GMPUtils.h"
|
||||
|
@ -281,21 +282,26 @@ GMPChild::RecvPreloadLibs(const nsCString& aLibs)
|
|||
// Pre-load DLLs that need to be used by the EME plugin but that can't be
|
||||
// loaded after the sandbox has started
|
||||
// Items in this must be lowercase!
|
||||
static const char *const whitelist[] = {
|
||||
"dxva2.dll", // Get monitor information
|
||||
"evr.dll", // MFGetStrideForBitmapInfoHeader
|
||||
"mfplat.dll", // MFCreateSample, MFCreateAlignedMemoryBuffer, MFCreateMediaType
|
||||
"msmpeg2vdec.dll", // H.264 decoder
|
||||
"psapi.dll", // For GetMappedFileNameW, see bug 1383611
|
||||
constexpr static const char16_t* whitelist[] = {
|
||||
u"dxva2.dll", // Get monitor information
|
||||
u"evr.dll", // MFGetStrideForBitmapInfoHeader
|
||||
u"mfplat.dll", // MFCreateSample, MFCreateAlignedMemoryBuffer, MFCreateMediaType
|
||||
u"msmpeg2vdec.dll", // H.264 decoder
|
||||
u"psapi.dll", // For GetMappedFileNameW, see bug 1383611
|
||||
};
|
||||
constexpr static bool (*IsASCII)(const char16_t*) = NS_ConstExprIsAscii;
|
||||
static_assert(AllOf(std::begin(whitelist), std::end(whitelist), IsASCII),
|
||||
"Items in the whitelist must not contain non-ASCII "
|
||||
"characters!");
|
||||
|
||||
nsTArray<nsCString> libs;
|
||||
SplitAt(", ", aLibs, libs);
|
||||
for (nsCString lib : libs) {
|
||||
ToLowerCase(lib);
|
||||
for (const char* whiteListedLib : whitelist) {
|
||||
if (lib.EqualsASCII(whiteListedLib)) {
|
||||
LoadLibraryA(lib.get());
|
||||
for (const char16_t* whiteListedLib : whitelist) {
|
||||
if (nsDependentString(whiteListedLib).EqualsASCII(lib.Data(),
|
||||
lib.Length())) {
|
||||
LoadLibraryW(char16ptr_t(whiteListedLib));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче