fix: Add more checks in MojoCdmService. (#20219)

Applies b7b305f338%5E%21/
This commit is contained in:
Samuel Attard
2019-09-17 10:53:04 -07:00
committed by John Kleinschmidt
parent e3be323962
commit f2d1abd0e3
3 changed files with 45 additions and 1 deletions

View File

@@ -83,3 +83,4 @@ crashpad_pid_check.patch
fix_use_weakptr_to_detect_deletion.patch
fix_disabling_compositor_recycling.patch
allow_new_privileges_in_unsandboxed_child_processes.patch
fix_add_more_checks_in_mojocdmservice.patch

View File

@@ -6,7 +6,7 @@ Subject: allow new privileges in unsandboxed child processes
This allows unsandboxed renderers to launch setuid processes on Linux.
diff --git a/content/browser/child_process_launcher_helper_linux.cc b/content/browser/child_process_launcher_helper_linux.cc
index 720b92a1a3a7ab5512f839005b272e4989d2ac65..b1759109627cd00053489dcdd397e942fa9d289f 100644
index 5b82388932eb845a0cf932ee2b04ece51c474d1c..6cfa4c8f34fe382fe5db6cd31dd56967a45f3bf4 100644
--- a/content/browser/child_process_launcher_helper_linux.cc
+++ b/content/browser/child_process_launcher_helper_linux.cc
@@ -54,6 +54,18 @@ bool ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread(

View File

@@ -0,0 +1,43 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Pedro Pontes <pepontes@microsoft.com>
Date: Thu, 12 Sep 2019 16:28:47 +0200
Subject: fix: Add more checks in MojoCdmService.
Applies https://chromium.googlesource.com/chromium/src.git/+/b7b305f3389017cc42e2cfac6e7a319f42d5bde3%5E%21/
diff --git a/media/mojo/services/mojo_cdm_service.cc b/media/mojo/services/mojo_cdm_service.cc
index 1ccfd2f05a7c56d6a867bbcc7b04aed948b73b15..a3f8332768b2e1c6375b5f643acb197a55521f83 100644
--- a/media/mojo/services/mojo_cdm_service.cc
+++ b/media/mojo/services/mojo_cdm_service.cc
@@ -63,7 +63,9 @@ void MojoCdmService::Initialize(const std::string& key_system,
const CdmConfig& cdm_config,
InitializeCallback callback) {
DVLOG(1) << __func__ << ": " << key_system;
- DCHECK(!cdm_);
+
+ CHECK(!has_initialize_been_called_) << "Initialize should only happen once";
+ has_initialize_been_called_ = true;
auto weak_this = weak_factory_.GetWeakPtr();
cdm_factory_->Create(
@@ -157,6 +159,7 @@ void MojoCdmService::OnCdmCreated(
return;
}
+ CHECK(!cdm_) << "CDM should only be created once.";
cdm_ = cdm;
if (context_) {
diff --git a/media/mojo/services/mojo_cdm_service.h b/media/mojo/services/mojo_cdm_service.h
index fd265467859f86c97f16f6abb2cef19ad5b3e139..1e575474f5bcde434af1f55c0361a30e42ac6f29 100644
--- a/media/mojo/services/mojo_cdm_service.h
+++ b/media/mojo/services/mojo_cdm_service.h
@@ -101,6 +101,8 @@ class MEDIA_MOJO_EXPORT MojoCdmService : public mojom::ContentDecryptionModule {
// Callback for when |decryptor_| loses connectivity.
void OnDecryptorConnectionError();
+ bool has_initialize_been_called_ = false;
+
CdmFactory* cdm_factory_;
MojoCdmServiceContext* const context_ = nullptr;
scoped_refptr<::media::ContentDecryptionModule> cdm_;