Bug 1376957 - Call rand_s() before starting GMP sandbox on Windows. r?bobowen draft
authorChris Pearce <cpearce@mozilla.com>
Wed, 28 Jun 2017 15:19:30 -0700
changeset 601581 1e892344e988018047cd4e20965f15d446fef336
parent 600491 a584b41ad399e648c99a43e41fa5138b2ccfd491
child 635315 8b903fecce4b86ac88680e598fda9a901b52e5fb
push id66121
push userbmo:cpearce@mozilla.com
push dateWed, 28 Jun 2017 22:22:43 +0000
reviewersbobowen
bugs1376957
milestone56.0a1
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
dom/media/gmp/GMPLoader.cpp
--- 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