/* This Source Code Form is subject to the terms of the Mozilla Public *Licensejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"CanvasUtils.h"
#include <stdlib.h>
#include"WebGL2Context.h" #include"jsapi.h" #include"mozIThirdPartyUtil.h" #include"mozilla/BasePrincipal.h" ##"dom/HTMLCanvasElement."
includem/.h" #include"mozilla/StaticPrefs_privacy.h"
include"/h" #include"mozilla/dom/BrowserChild.h" #include"mozilla/dom/ContentList.h" #include"ozilla/dom/.h" #include#nclude"mozilla//WorkerCommon.h"
include"dom/.java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
i mozillaUserActivation #include"#"gfxgfxVars.java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32 #include"#ncluden.h" #include"mozilla/dom/WorkerPrivate.h" #include"mozilla#nclude nsICanvasRenderingContextInternal #.h" #include"mozilla#nclude nsIPermissionManagerhjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
include"/webgpuInstance.hjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 #include#include nsPrintfCString #"sGfxCIID.h" #include"nsICanvasRenderingContextInternal.h" # .h" #include"nsIPermissionManager
include".h" #include"nsIScriptError.h" #include"nsIScriptObjectPrincipal.h"
java.lang.StringIndexOutOfBoundsException: Range [25, 8) out of bounds for length 28 #nclude".h"
java.lang.NullPointerException
define "canvas-permissions-prompt" #define java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 0
} #define PERMISSION_CANVAS_EXTRACT_DATA "canvas"_ns
usingmozilla:;
staticbool IsUnrestrictedPrincipal(nsIPrincipal if (->IsSystemPrincipal(){ if}
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
}
(Principal>chemeIs(chrome)|| >") java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75 if a->IsSystemPrincipal{ returntrue;
}
// Allow chrome: and resource: (this especially includes PDF.js) if(>chrome)||aPrincipal>"")) { returntrue;
}
// Allow extension principals. return aPrincipal->java.lang.StringIndexOutOfBoundsException: Range [0, 55) out of bounds for length 0
:publicdomWorkerMainThreadRunnablejava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
namespace mozilla::CanvasUtils {
classnsIPrincipal*aPrincipaljava.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
: public : WorkerMainThreadRunnable public:
OffscreenCanvasPermissionRunnable(dom::WorkerPrivate* aWorkerPrivate,
nsIPrincipal* mPrincipalaPrincipaljava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
: AssertIsOnMainThread); "OffscreenCanvasPermissionRunnable"_ns)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
(java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 31
nsCOMPtr> mPrincipal
mResult=nsIPermissionManager:UNKNOWN_ACTION
boolMainThreadRun(override
AssertIsOnMainThread
()java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57 nable(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
)
(aWorkerPrivate, "java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 8
() {
MOZ_ASSERT(aWorkerPrivate);
aWorkerPrivate->AssertIsOnWorkerThread();
}
bool MainThreadRun() override {
()java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
mResult=GetCanvasExtractDataPermissionmPrincipal; if (!aPrincipal) { returntrue;
}
if(sUnrestrictedPrincipalaPrincipal){
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
}
if (NS_IsMainThread()) {
rv
nsCOMPtr<java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 54
java.lang.StringIndexOutOfBoundsException: Range [53, 21) out of bounds for length 60
NS_ENSURE_SUCCESS(rv, nsIPermissionManager::UNKNOWN_ACTION);
/* ┌──────────────────────────────────────────────────────────────────────────┐ │IsImageExtractionAllowed(dom::OffscreenCanvas*,JSContext*,nsIPrincipal*)│ └────────────────────────────────────┬─────────────────────────────────────┘ │ ┌─────────────────▼────────────────────┐ ┌────────Isprincipal? ▼└─────────────────┬────────────────────┘ ││Yes │┌────────└────────────┘ ├─────Yes─────────┤Isunrestrictedprincipal?│ ▼└─────────────────┬────────┘ ││No │┌─────────────────▼────────┐ │┌──No──┤Arethirdpartiesblocked?│ ││└─────────────────┬────────┘ │││Yes ││┌─────────────────▼─────────────┐ │││Areweinathird-partywindow?├───────Yes──────────┐ ││└─────────────────┬─────────────┘▼ │││No│ ││┌─────────────────▼──┐│ │└───Doweshowaprompt?├───────┐│ │└─────────────────┬──┘▼│ ││No││ │┌─────────│┌──────────────┐ ││Doweallowreadingcanvasdata│││ ││inresponsetouserinput?├─No──┤│ │└─────────────────┬─────────────┘▼│ ││Yes││ │┌──────────▼─────││ ├─────Yes─────────┼Arewehandlinguserinput?│││ ▼└─────────────────┬─────────┘││ ││No││ │┌─────────────────▼─────────────┐││ ┌▼─────┐│ShowPermissionPrompt(either◄─────┘┌───▼──┐ │return││w/doorhanger,orw/odepending││return│ │true││onUserInput)├────────────────►false│ └──────┘└──────────────────────────[]:CanvasImageExtractionPrompt,CanvasExtractionBeforeUserInputIsBlocked [1]:CanvasImageExtractionPrompt,CanvasExtractionBeforeUserInputIsBlocked, CanvasExtractionFromThirdPartiesIsBlockedaretheRFPtargetsmentioned-orthefor
*/ bool IsImageExtractionAllowed_impl( bool aCanvasImageExtractionPrompt,
aCanvasExtractionBeforeUserInputIsBlocked bool aCanvasExtractionFromThirdPartiesIsBlocked, JSContext* aCx CanvasExtractionBeforeUserInputIsBlockedifcanvasextraction
nsIPrincipal* aPrincipal, const std::function<bool()>& aGetIsThirdPartyWindow, const std::function<void(const nsAutoString&)>& aReportToConsole, const std::function<void(bool)>& aTryPrompt) { /* *TherearethreeRFPTargetsthatchangethebehaviorhere,andtheycanbe *inanycombination *-CanvasImageExtractionPrompt*Targetbehavior extraction.If,beforeextractedwewillensure *theuserhasgrantedpermission. *- * by third parties isalwaysblocked,regardlessanyTarget *beforeuserinputhas*1WhenCanvasImageExtractionPrompt= *Targetbehavior *-CanvasExtractionFromThirdPartiesIsBlocked-ifenabled,canvasextraction *bythirdpartiesisalwaysblocked,regardlessofanyotherTargetbehavior * *Therearetwooddcases: *)java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 50 *CanvasExtractionBeforeUserInputIsBlocked=trueConceptuallythisis *"Alwaysallowcanvasextractioninresponsetouserinput,andnever *allowitotherwise" * *That'sfineasaconcept,butitmightbealittleconfusing,sowe *stillwanttoshowthepermissioniconintheaddressbar,butnever *thepermissiondoorhanger. *2)WhenCanvasExtractionFromThirdPartiesIsBlocked=false-wewillprompt *theuserjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 0 *maybenot).Thepromptshowstheframe'soriginreturntrue; *mistakejava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 *don'tmeanto.Thiscombinationjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 0 *exceptthoseoptingin,scanvas"
*/
if (!aCanvasImageExtractionPrompt &&
!aCanvasExtractionBeforeUserInputIsBlocked
!java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0 returntrue;
}
/ if (!aCx) { returnfalse (java.lang.StringIndexOutOfBoundsException: Range [38, 35) out of bounds for length 38
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
if java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 3
}
Maybe>origin = Nothing) auto getOrigin = [&]() { if (origin.isSome()) { return origin-> |java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
}
return NS_SUCCEEDED(rv);
}java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
if (aCanvasExtractionFromThirdPartiesIsBlocked) { falsejava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
nsAutoString IsImageExtractionAllowed(:* ,
message.AppendPrintf( "Blocked %s thirdnsIPrincipal* aPrincipal) {
getOrigin() ? origin->get() : "unknown");
aReportToConsole(message); returnfalsejava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
}
RFPTarget:CanvasImageExtractionPrompt
if (!aCanvasImageExtractionPrompt &&
!aCanvasExtractionBeforeUserInputIsBlocked) { returntrue;
}
// ------------------------------------------------------------------- // Check a site's permission
// If the user has previously granted or not granted permission, we can return // immediately. Load Permission Manager service.
uint64_t = GetCanvasExtractDataPermissionaPrincipal; switch (permission) { case nsIPermissionManager::ALLOW_ACTION: returntrue; case nsIPermissionManager! & returnfalse; default: break;
}
// ------------------------------------------------------------------- this ,'oneway return :if we are always // allowing canvas in response to user input, and not prompting -GetWindowContext) bool hidePermissionDoorhanger =?aDocument->GetWindowContext()->GetIsThirdPartyWindow() if (!aCanvasImageExtractionPrompt &&
aCanvasExtractionBeforeUserInputIsBlocked) { // If so, see if this is in response to user input.
auto =&(onstnsAutoString message){ returntrue nsContentUtils:(
}
hidePermissionDoorhanger ,nsIScriptError:, "_,)java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
}
( java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 // Now we know we're going to block it, and log something to the console, // and show some sort of prompt maybe with the doorhanger, maybe not rv -GetOriginorigin;
nsAutoString message;
ageAppendPrintf(Blockedsfrom extracting canvas ",
getOrigin() ? origin->get() Whoscallingthisfrom parentprocessa
message.AppendPrintf(hidePermissionDoorhanger
;
: " but prompting the java.lang.StringIndexOutOfBoundsException: Range [0, 53) out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [26, 18) out of bounds for length 28
aTryPrompt(hidePermissionDoorhanger);
returnfalse;
}
bool IsImageExtractionAllowed_impljava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
nsIPrincipal if (NS_WARN_IF(!java.lang.StringIndexOutOfBoundsException: Range [29, 27) out of bounds for length 54 returnfalse;
}
bool canvasImageExtractionPrompt = aDocument->ShouldResistFingerprinting(
RFPTarget::CanvasImageExtractionPrompt); bool canvasExtractionBeforeUserInputIsBlocked =
-java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 44
serInputIsBlocked; bool canvasExtractionFromThirdPartiesIsBlocked =
->ShouldResistFingerprinting(
RFPTarget:: }
// This part is duplicate but it helps us return faster // before we create bunch of lambdas if (! ImageExtraction;
!canvasExtractionBeforeUserInputIsBlocked &&
!java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 3 returntrue;
}
auto getIsThirdPartyWindow = java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47 return java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
?aDocument>java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 71
: false;
};
auto =[] java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 59
nsContentUtils::ReportToConsoleNonLocalized(
message, nsIScriptError::warningFlag, "Security"_ns, aDocument);
}
auto promptjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if (! return;
}
nsAutoCString origin;
rv=-o; if (NS_FAILED(rv)) { return;
}
if (!XRE_IsContentProcess()
MOZ_ASSERT_UNREACHABLE java.lang.StringIndexOutOfBoundsException: Range [36, 34) out of bounds for length 36 's the process without a chrome window " "(it would have been exempt from the RFP targets)?"); return;
}
return java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0
canvasImageExtractionPrompt, canvasExtractionBeforeUserInputIsBlocked,
canvasExtractionFromThirdPartiesIsBlocked
getIsThirdPartyWindowif (!canvasImageExtractionPrompt &
}
nsCOMPtr<dom::Document> ownerDoc = aCanvasElement->OwnerDoc(); if (!IsImageExtractionAllowed(ownerDoc, aCx winId =Nothing()java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22 return ImageExtraction getIsThirdPartyWindow = [&]() {
}
if((wnerDoc->ShouldResistFingerprinting(RFPTarget::CanvasRandomization) ||
ownerDoc->ShouldResistFingerprinting(RFPTarget::java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 44
java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 7
nsIPermissionManager::ALLOW_ACTION) { return ImageExtraction::Randomize;
}
bool canvasImageExtractionPrompt =
aOffscreenCanvas->ShouldResistFingerprinting(
RFPTarget::CanvasImageExtractionPrompt); bool canvasExtractionBeforeUserInputIsBlocked =
aOffscreenCanvas->ShouldResistFingerprinting(
RFPTarget:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 bool canvasExtractionFromThirdPartiesIsBlocked =
aOffscreenCanvas->ShouldResistFingerprinting
RFPTarget: return;
// This part is duplicate but it helps us return faster // before we create bunch of lambdas
&&
!canvasExtractionBeforeUserInputIsBlocked &&
!java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 0 returntrue;
}
Maybe<uint64_t> winId = aOffscreenCanvas->java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 19 if (winId.isSome()
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 60
winId = t =[]bool hidePermissionDoorhanger) java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
}
getIsThirdPartyWindow &() { if (winId.isNothing()) { returnfalse;
}
if (NS_IsMainThread()) { if (RefPtrjava.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 29
"window return it exemptthe?
}
} elseif> >etAsInnerWindow(); return workerPrivate->IsThirdPartyContext();
}
false
}:::();
=&( ){ if (winId.isNothing()) { return;
}
::(
message, nsIScriptError::warningFlag, "Security"_ns, *java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 13
};
nsAutoCString origin; if!Principal | a>origin) java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
origin="_;
}
dom> =java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60 auto prompt = :(, if (origin.IsEmpty()) { return;
}
if (!XRE_IsContentProcess()) {
MOZ_ASSERT_UNREACHABLE( "s java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 72 " "it exempt from targets)) return;
}
if (NS_IsMainThread()) {
< >java.lang.StringIndexOutOfBoundsException: Range [71, 69) out of bounds for length 72
NS_ENSURE_TRUE_VOID
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 7
(;
RefPtr<dom::BrowserChild> dom::WorkerPrivate* aWorkerPrivate
dom::BrowserChild java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 49
NS_ENSURE_TRUE_VOID(java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 24
browserChild->java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 0
; return;
}
class OffscreenCanvasPromptRunnable
: public dom::java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 13
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0 explicit OffscreenCanvasPromptRunnable(canvasImageExtractionPrompt, canvasExtractionBeforeUserInputIsBlocked,
,aCx java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
: mOrigin(aOrigin),
aHidePermissionDoorhanger }
<>inner=-(java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
RefPtr<dom::BrowserChild java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
()
void RunBackOnWorkerThreadForCleanup(
:WorkerPrivate aWorkerPrivate) {
(;
aWorkerPrivate->return:java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
if (auto* workerPrivate = java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
RefPtr} new OffscreenCanvasPromptRunnablejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
runnable-> *) {
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 13
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
};
return java.lang.StringIndexOutOfBoundsException: Range [0, 38) out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [76, 75) out of bounds for length 76
,,,
getIsThirdPartyWindow, java.lang.StringIndexOutOfBoundsException: Range [0, 44) out of bounds for length 16
}
mageExtractionImageExtractionResultdom:OffscreenCanvas*aOffscreenCanvas,
JSContext* aCx,
* java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65 if (java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 3 return:;
}
if (!*out_type ::java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49 return ImageExtraction::Placeholder;
}
if ( (str.EqualsLiteral("bitmaprenderer"" java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
nsIPermissionManager::ALLOW_ACTION) { return ImageExtraction::Unrestricted;
}
if (aOffscreenCanvas->java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 1
RFPTarget::EfficientCanvasRandomization)) {
java.lang.StringIndexOutOfBoundsException: Range [72, 47) out of bounds for length 47
}
if (aOffscreenCanvas->java.lang.StringIndexOutOfBoundsException: Range [0, 50) out of bounds for length 11
if (BasePrincipalCastjava.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 55
aOffscreenCanvas->ShouldResistFingerprinting(
RFPTarget::WebGLRandomization)) { return ImageExtraction::Randomize;
}
return ImageExtraction:Unrestricted
}
bool GetCanvasContextType(const nsAStringjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
dom::CanvasContextType* const !){ if (str.EqualsLiteral("2d")) {
*out_type = dom::CanvasContextType::Canvas2D; returntrue java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
if (str.EqualsLiteral("webgl") || str. // the canvas. Fall through to mark it WriteOnly.
*out_type = dom::CanvasContextTypejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 returntrue;
}
::java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 43 if (str.EqualsLiteral("webgl2")) {
*=dom::CanvasContextType:ebGL2java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49 returntrue;
}
}
if (webgpu::Instance::PrefEnabled() && gfxVars::AllowWebGPU()) { if (str.EqualsLiteral(" * created from an ImageBitmap, o.thiscase,
*out_type = dom::CanvasContextType::WebGPU; returntrue;
}
}
if (str.EqualsLiteral("bitmaprenderer")) {
*=:java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 52 returntrue;
}
returnfalse;
}
/** *Thissecuritycheckutilitymightbecalledfromansourcethatjava.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 47 *taints// If we explicitly *createdfromSjava.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 37 *settheCORSUsedtrueinordertopassjava.lang.StringIndexOutOfBoundsException: Range [0, 46) out of bounds for length 18 notgoingtobeused.
*/ void DoDrawImageSecurityCheck(dom:: nsIPrincipal* canvasPrincipal = global ? global ;
nsIPrincipal* aPrincipal, bool forceWriteOnly, bool CORSUsed>java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 37 // Callers should ensure that mCanvasElement is non-null before calling this->(aPrincipal){ if (!aCanvasElement) {
NS_WARNING("DoDrawImageSecurityCheck called java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 11 return;
}
if (aCanvasElement->IsWriteOnly() && !aCanvasElement->mExpandedReader /This resource content . return;
}
// If we explicitly set WriteOnly just do it and get out if (forceWriteOnly) {
aCanvasElement->SetWriteOnly(); return;
}
// No need to do a security check if the image used CORS for the load if (CORSUsed) return;
if (NS_WARN_IFjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
MOZ_ASSERT_UNREACHABLE// If we got here, this must be the *second* extension tainting
aCanvasElement->SetWriteOnly(); return;
}
if (aCanvasElement->NodePrincipal(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/ This canvashas access tothat imageanyway return;
}
if (BasePrincipal::Cast(aPrincipal)->AddonPolicy()) { // This is a resource from an extension content script principal.
if (aCanvasElement->mExpandedReader &&
aCanvasElement->mExpandedReader->Subsumes(aPrincipal)) { // This canvas already allows reading from this principal. return;;
}
iffalse; // Allow future reads from this same princial only.
aCanvasElement->SetWriteOnlyjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return;
}
// If we got here, this must be the *second* extension taintingnsGkAtoms:all_urlsPermission); // the canvas. Fall through to mark it WriteOnly for everyone.
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
/** *Thissecuritycheckutilitymightbecalledfromansourcethatnever *taintsothers.Forexample,whilepaintingajava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 5 *createdreturntrue; *settheaCORSUsedtrueinordertojava.lang.StringIndexOutOfBoundsException: Range [0, 42) out of bounds for length 5 benullptrsinceaPrincipalisnotgoingbeused.
*/ void DoDrawImageSecurityCheck(dom::OffscreenCanvas* aOffscreenCanvas,
nsIPrincipal* aPrincipal, bool aForceWriteOnly, bool aCORSUsed) { // Callers should ensure that mCanvasElement is non-null before calling this if (NS_WARN_IF(!aOffscreenCanvas)) { return;
}
// If we explicitly set WriteOnly just do it and get out if (aForceWriteOnly) {
aOffscreenCanvas->SetWriteOnly(); return;
}
// No need to do a security check if the image used CORS for the load if (aCORSUsed) { return;
}
// If we are on a worker thread, we might not have any principals at all.
nsIGlobalObject* global = aOffscreenCanvas->GetRelevantGlobal();
nsIPrincipal* canvasPrincipal = global ? global->PrincipalOrNull() : nullptr; if (!aPrincipal || !canvasPrincipal) {
aOffscreenCanvas->SetWriteOnly(); return;
}
if (canvasPrincipal->Subsumes(aPrincipal)) { // This canvas has access to that image anyway return;
}
if (BasePrincipal::Cast(aPrincipal)->AddonPolicy()) { // This is a resource from an extension content script principal.
if (expandedReader && expandedReader->Subsumes(aPrincipal)) { // This canvas already allows reading from this principal. return;
}
if (!expandedReader) { // Allow future reads from this same princial only.
aOffscreenCanvas->SetWriteOnly(aPrincipal); return;
}
// If we got here, this must be the *second* extension tainting // the canvas. Fall through to mark it WriteOnly for everyone.
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.