Bug 1375708 - Use base::Time() instead of time(0) in WidevineDecryptor::GetCurrentWallTime(). r=gerald, a=jcristau
authorChris Pearce <cpearce@mozilla.com>
Fri, 23 Jun 2017 16:02:14 +1200
changeset 414118 7bda5dde85650defd4ad714ba9c869e09f0d183d
parent 414117 d36fe4881abb21f2c472810352eca9ae119a0b38
child 414119 af94af58d1f315f475fbe831bb48aecbeb9a0c61
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, jcristau
bugs1375708
milestone55.0
Bug 1375708 - Use base::Time() instead of time(0) in WidevineDecryptor::GetCurrentWallTime(). r=gerald, a=jcristau On Linux some implementations of time(0) appear to be suffering from integer overflow and giving us the wrong dates. This causes the time we expose to the CDM to be wrong, and so licenses passed to the CDM are failing to authenticate, and Netflix is thus broken on some Linux systems. This is only happening in Firefox 54 and earlier, as in those versions we use the WidevineDecryptor to talk to the CDM. In 55 (in beta) and later we use the PChromiumCDM protocol to talk to the CDM. This doesn't use time(0) to get a time for the CDM, so it's immune to the problem here. So this patch makes the GetCurrentWallTime() implementation in WidevineDecryptor match the code currently being used on Nightly and Beta in the ChromiumCDMChild::GetCurrentWallTime() function. Since we use the PChromiumCDM protocol to talk to the CDM on Nightly and Beta by default, the WidevineDecryptor isn't actually being used on Nightly and Beta. So this patch will only cause a behaviour change in Release, which still uses the old backend. However it will make Release run the same code that we're running in Nightly and Beta, so it should be safe to uplift to Release. MozReview-Commit-ID: J58iDyinyQG
dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
dom/media/gmp/widevine-adapter/moz.build
--- a/dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WidevineDecryptor.h"
 
 #include "WidevineAdapter.h"
 #include "WidevineUtils.h"
 #include "WidevineFileIO.h"
 #include <stdarg.h>
+#include "base/time.h"
 
 using namespace cdm;
 using namespace std;
 
 namespace mozilla {
 
 static map<uint32_t, RefPtr<CDMWrapper>> sDecryptors;
 
@@ -233,21 +234,17 @@ WidevineDecryptor::SetTimer(int64_t aDel
   if (mCDM) {
     GMPSetTimerOnMainThread(new TimerTask(this, mCDM, aContext), aDelayMs);
   }
 }
 
 Time
 WidevineDecryptor::GetCurrentWallTime()
 {
-  GMPTimestamp gmpTime = 0;
-  GMPGetCurrentTime(&gmpTime);
-  double t = (double)gmpTime / 1e3;
-  CDM_LOG("Decryptor::GetCurrentWallTime()= %lf", t);
-  return t;
+  return base::Time::Now().ToDoubleT();
 }
 
 void
 WidevineDecryptor::OnResolveNewSessionPromise(uint32_t aPromiseId,
                                               const char* aSessionId,
                                               uint32_t aSessionIdSize)
 {
   if (!mCallback) {
--- a/dom/media/gmp/widevine-adapter/moz.build
+++ b/dom/media/gmp/widevine-adapter/moz.build
@@ -24,8 +24,10 @@ EXPORTS += [
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '/dom/media/gmp',
 ]
 
 if CONFIG['CLANG_CXX']:
     CXXFLAGS += ['-Wno-error=shadow']
+
+include('/ipc/chromium/chromium-config.mozbuild')