From eff2a84faef5afe0bd871e7f8c30de8e2e77f777 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Mon, 22 Feb 2021 19:00:10 +0000 Subject: [PATCH] Bug 1678255 - avoid crashing if trying to initialize a fission frameloader with a nullprincipal, r=ckerschb,nika Differential Revision: https://phabricator.services.mozilla.com/D104865 --- dom/ipc/ContentParent.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index c0bd232328a2..da487dbd8cb2 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -901,7 +901,10 @@ static already_AddRefed CreateRemoteTypeIsolationPrincipal( nsAutoCString origin( Substring(aRemoteType, offset, aRemoteType.Length() - offset)); - return BasePrincipal::CreateContentPrincipal(origin); + nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); + nsCOMPtr principal; + ssm->CreateContentPrincipalFromOrigin(origin, getter_AddRefs(principal)); + return principal.forget(); } /*static*/ @@ -1429,7 +1432,8 @@ bool ContentParent::ValidatePrincipal( return true; } - if (RemoteTypePrefix(mRemoteType) != FISSION_WEB_REMOTE_TYPE) { + if (!mRemoteTypeIsolationPrincipal || + RemoteTypePrefix(mRemoteType) != FISSION_WEB_REMOTE_TYPE) { return true; }