Bug 1376957 - Call rand_s() before starting GMP sandbox on Windows. r?bobowen
The loading of Widevine CDM 970 is being blocked on Windows 7 by our sandbox
when the CDM calls RtlGenRandom(). Chrome is calling s_rand() before enabling
the sandbox [1] in order to load the appropriate DLLs so that the call
succeeds, so we should do the same.
[1] https://cs.chromium.org/chromium/src/content/ppapi_plugin/ppapi_thread.cc?l=424&rcl=d0d190c09619cb359296999438551b66f0e1cdb1
MozReview-Commit-ID: IvmlQY0ohHc
--- a/dom/media/gmp/GMPLoader.cpp
+++ b/dom/media/gmp/GMPLoader.cpp
@@ -155,16 +155,22 @@ GMPLoader::SetSandboxInfo(MacSandboxInfo
#endif
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
class WinSandboxStarter : public mozilla::gmp::SandboxStarter
{
public:
bool Start(const char *aLibPath) override
{
+ // Cause advapi32 to load before the sandbox is turned on, as
+ // Widevine version 970 and later require it and the sandbox
+ // blocks it on Win7.
+ unsigned int dummy_rand;
+ rand_s(&dummy_rand);
+
mozilla::SandboxTarget::Instance()->StartSandbox();
return true;
}
};
#endif
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
class MacSandboxStarter : public mozilla::gmp::SandboxStarter