mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1579357 - Check the arguments in BasePrincipal XPCOM methods, r=jkt
Differential Revision: https://phabricator.services.mozilla.com/D45001 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
9cede8d015
commit
41fd92503f
@ -292,7 +292,7 @@ bool BasePrincipal::Subsumes(nsIPrincipal* aOther,
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::Equals(nsIPrincipal* aOther, bool* aResult) {
|
||||
NS_ENSURE_TRUE(aOther, NS_ERROR_INVALID_ARG);
|
||||
NS_ENSURE_ARG_POINTER(aOther);
|
||||
|
||||
*aResult = FastEquals(aOther);
|
||||
|
||||
@ -301,7 +301,7 @@ BasePrincipal::Equals(nsIPrincipal* aOther, bool* aResult) {
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::EqualsConsideringDomain(nsIPrincipal* aOther, bool* aResult) {
|
||||
NS_ENSURE_TRUE(aOther, NS_ERROR_INVALID_ARG);
|
||||
NS_ENSURE_ARG_POINTER(aOther);
|
||||
|
||||
*aResult = FastEqualsConsideringDomain(aOther);
|
||||
|
||||
@ -310,7 +310,7 @@ BasePrincipal::EqualsConsideringDomain(nsIPrincipal* aOther, bool* aResult) {
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::Subsumes(nsIPrincipal* aOther, bool* aResult) {
|
||||
NS_ENSURE_TRUE(aOther, NS_ERROR_INVALID_ARG);
|
||||
NS_ENSURE_ARG_POINTER(aOther);
|
||||
|
||||
*aResult = FastSubsumes(aOther);
|
||||
|
||||
@ -319,7 +319,7 @@ BasePrincipal::Subsumes(nsIPrincipal* aOther, bool* aResult) {
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::SubsumesConsideringDomain(nsIPrincipal* aOther, bool* aResult) {
|
||||
NS_ENSURE_TRUE(aOther, NS_ERROR_INVALID_ARG);
|
||||
NS_ENSURE_ARG_POINTER(aOther);
|
||||
|
||||
*aResult = FastSubsumesConsideringDomain(aOther);
|
||||
|
||||
@ -329,7 +329,7 @@ BasePrincipal::SubsumesConsideringDomain(nsIPrincipal* aOther, bool* aResult) {
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::SubsumesConsideringDomainIgnoringFPD(nsIPrincipal* aOther,
|
||||
bool* aResult) {
|
||||
NS_ENSURE_TRUE(aOther, NS_ERROR_INVALID_ARG);
|
||||
NS_ENSURE_ARG_POINTER(aOther);
|
||||
|
||||
*aResult = FastSubsumesConsideringDomainIgnoringFPD(aOther);
|
||||
|
||||
@ -339,6 +339,8 @@ BasePrincipal::SubsumesConsideringDomainIgnoringFPD(nsIPrincipal* aOther,
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::CheckMayLoad(nsIURI* aURI, bool aReport,
|
||||
bool aAllowIfInheritsPrincipal) {
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
|
||||
// Check the internal method first, which allows us to quickly approve loads
|
||||
// for the System Principal.
|
||||
if (MayLoadInternal(aURI)) {
|
||||
|
@ -205,6 +205,8 @@ class BasePrincipal : public nsJSPrincipals {
|
||||
* of whether they subsume the document principal.
|
||||
*/
|
||||
bool OverridesCSP(nsIPrincipal* aDocumentPrincipal) {
|
||||
MOZ_ASSERT(aDocumentPrincipal);
|
||||
|
||||
// Expanded principals override CSP if and only if they subsume the document
|
||||
// principal.
|
||||
if (mKind == eExpandedPrincipal) {
|
||||
@ -264,6 +266,8 @@ class BasePrincipal : public nsJSPrincipals {
|
||||
};
|
||||
|
||||
inline bool BasePrincipal::FastEquals(nsIPrincipal* aOther) {
|
||||
MOZ_ASSERT(aOther);
|
||||
|
||||
auto other = Cast(aOther);
|
||||
if (Kind() != other->Kind()) {
|
||||
// Principals of different kinds can't be equal.
|
||||
@ -287,6 +291,8 @@ inline bool BasePrincipal::FastEquals(nsIPrincipal* aOther) {
|
||||
}
|
||||
|
||||
inline bool BasePrincipal::FastEqualsConsideringDomain(nsIPrincipal* aOther) {
|
||||
MOZ_ASSERT(aOther);
|
||||
|
||||
// If neither of the principals have document.domain set, we use the fast path
|
||||
// in Equals(). Otherwise, we fall back to the slow path below.
|
||||
auto other = Cast(aOther);
|
||||
@ -299,6 +305,8 @@ inline bool BasePrincipal::FastEqualsConsideringDomain(nsIPrincipal* aOther) {
|
||||
}
|
||||
|
||||
inline bool BasePrincipal::FastSubsumes(nsIPrincipal* aOther) {
|
||||
MOZ_ASSERT(aOther);
|
||||
|
||||
// If two principals are equal, then they both subsume each other.
|
||||
if (FastEquals(aOther)) {
|
||||
return true;
|
||||
@ -309,6 +317,8 @@ inline bool BasePrincipal::FastSubsumes(nsIPrincipal* aOther) {
|
||||
}
|
||||
|
||||
inline bool BasePrincipal::FastSubsumesConsideringDomain(nsIPrincipal* aOther) {
|
||||
MOZ_ASSERT(aOther);
|
||||
|
||||
// If neither of the principals have document.domain set, we hand off to
|
||||
// FastSubsumes() which has fast paths for some special cases. Otherwise, we
|
||||
// fall back to the slow path below.
|
||||
@ -321,6 +331,8 @@ inline bool BasePrincipal::FastSubsumesConsideringDomain(nsIPrincipal* aOther) {
|
||||
|
||||
inline bool BasePrincipal::FastSubsumesIgnoringFPD(
|
||||
nsIPrincipal* aOther, DocumentDomainConsideration aConsideration) {
|
||||
MOZ_ASSERT(aOther);
|
||||
|
||||
if (Kind() == eContentPrincipal &&
|
||||
!dom::ChromeUtils::IsOriginAttributesEqualIgnoringFPD(
|
||||
mOriginAttributes, Cast(aOther)->mOriginAttributes)) {
|
||||
|
Loading…
Reference in New Issue
Block a user