зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1526891 - Part 4: Add QuotaManager::IsPrincipalInfoValid checks to all quota clients; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D20913
This commit is contained in:
Родитель
105d16dc03
Коммит
dea641b977
|
@ -1148,6 +1148,11 @@ PAsmJSCacheEntryParent* AllocEntryParent(OpenMode aOpenMode,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(aPrincipalInfo))) {
|
||||
MOZ_ASSERT(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<ParentRunnable> runnable =
|
||||
new ParentRunnable(aPrincipalInfo, aOpenMode, aWriteParams);
|
||||
|
||||
|
@ -1408,6 +1413,11 @@ ChildRunnable::Run() {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(*principalInfo))) {
|
||||
Fail(JS::AsmJSCache_InternalError);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mPrincipalInfo = std::move(principalInfo);
|
||||
|
||||
PBackgroundChild* actor = BackgroundChild::GetOrCreateForCurrentThread();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "mozilla/dom/cache/PCacheChild.h"
|
||||
#include "mozilla/dom/cache/ReadStream.h"
|
||||
#include "mozilla/dom/cache/TypeUtils.h"
|
||||
#include "mozilla/dom/quota/QuotaManager.h"
|
||||
#include "mozilla/dom/WorkerPrivate.h"
|
||||
#include "mozilla/ipc/BackgroundChild.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
|
@ -38,6 +39,7 @@ namespace cache {
|
|||
|
||||
using mozilla::ErrorResult;
|
||||
using mozilla::Unused;
|
||||
using mozilla::dom::quota::QuotaManager;
|
||||
using mozilla::ipc::BackgroundChild;
|
||||
using mozilla::ipc::IProtocol;
|
||||
using mozilla::ipc::PBackgroundChild;
|
||||
|
@ -151,6 +153,12 @@ already_AddRefed<CacheStorage> CacheStorage::CreateOnMainThread(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(principalInfo))) {
|
||||
NS_WARNING("CacheStorage not supported on invalid origins.");
|
||||
RefPtr<CacheStorage> ref = new CacheStorage(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
bool testingEnabled =
|
||||
aForceTrustedOrigin ||
|
||||
Preferences::GetBool("dom.caches.testing.enabled", false) ||
|
||||
|
@ -191,6 +199,11 @@ already_AddRefed<CacheStorage> CacheStorage::CreateOnWorker(
|
|||
|
||||
const PrincipalInfo& principalInfo = aWorkerPrivate->GetPrincipalInfo();
|
||||
|
||||
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(principalInfo))) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// We have a number of cases where we want to skip the https scheme
|
||||
// validation:
|
||||
//
|
||||
|
|
|
@ -10,12 +10,14 @@
|
|||
#include "mozilla/dom/cache/ActorUtils.h"
|
||||
#include "mozilla/dom/cache/CacheOpParent.h"
|
||||
#include "mozilla/dom/cache/ManagerId.h"
|
||||
#include "mozilla/dom/quota/QuotaManager.h"
|
||||
#include "mozilla/ipc/PBackgroundParent.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace cache {
|
||||
|
||||
using mozilla::dom::quota::QuotaManager;
|
||||
using mozilla::ipc::PBackgroundParent;
|
||||
using mozilla::ipc::PrincipalInfo;
|
||||
|
||||
|
@ -23,6 +25,11 @@ using mozilla::ipc::PrincipalInfo;
|
|||
PCacheStorageParent* AllocPCacheStorageParent(
|
||||
PBackgroundParent* aManagingActor, Namespace aNamespace,
|
||||
const mozilla::ipc::PrincipalInfo& aPrincipalInfo) {
|
||||
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(aPrincipalInfo))) {
|
||||
MOZ_ASSERT(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new CacheStorageParent(aManagingActor, aNamespace, aPrincipalInfo);
|
||||
}
|
||||
|
||||
|
|
|
@ -12177,6 +12177,11 @@ Factory::AllocPBackgroundIDBFactoryRequestParent(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(principalInfo))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<ContentParent> contentParent =
|
||||
BackgroundParent::GetContentParent(Manager());
|
||||
|
||||
|
|
|
@ -133,6 +133,11 @@ nsresult IDBFactory::CreateForWindow(nsPIDOMWindowInner* aWindow,
|
|||
MOZ_ASSERT(principalInfo->type() == PrincipalInfo::TContentPrincipalInfo ||
|
||||
principalInfo->type() == PrincipalInfo::TSystemPrincipalInfo);
|
||||
|
||||
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(*principalInfo))) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webNav = do_GetInterface(aWindow);
|
||||
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(webNav);
|
||||
|
||||
|
@ -169,6 +174,10 @@ nsresult IDBFactory::CreateForMainThreadJS(JSContext* aCx,
|
|||
return rv;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(*principalInfo))) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
rv = CreateForMainThreadJSInternal(aCx, aOwningObject, principalInfo,
|
||||
aFactory);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
|
@ -584,6 +593,12 @@ already_AddRefed<IDBOpenDBRequest> IDBFactory::OpenInternal(
|
|||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(principalInfo))) {
|
||||
IDB_REPORT_INTERNAL_ERR();
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
principalInfo = *mPrincipalInfo;
|
||||
}
|
||||
|
|
|
@ -497,6 +497,11 @@ PBackgroundSDBConnectionParent* AllocPBackgroundSDBConnectionParent(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(aPrincipalInfo))) {
|
||||
ASSERT_UNLESS_FUZZING();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<Connection> actor = new Connection(aPrincipalInfo);
|
||||
|
||||
return actor.forget().take();
|
||||
|
|
|
@ -221,6 +221,10 @@ SDBConnection::Init(nsIPrincipal* aPrincipal) {
|
|||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!QuotaManager::IsPrincipalInfoValid(*principalInfo))) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
mPrincipalInfo = std::move(principalInfo);
|
||||
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче