Bug 1315905 - Cleanup Necko http security check - part 1, r=valentin a=ghang
--- a/netwerk/ipc/NeckoParent.cpp
+++ b/netwerk/ipc/NeckoParent.cpp
@@ -168,26 +168,30 @@ void CrashWithReason(const char * reason
}
const char*
NeckoParent::GetValidatedOriginAttributes(const SerializedLoadContext& aSerialized,
PContentParent* aContent,
nsIPrincipal* aRequestingPrincipal,
DocShellOriginAttributes& aAttrs)
{
- if (!aSerialized.IsNotNull()) {
- if (UsingNeckoIPCSecurity()) {
- CrashWithReason("GetValidatedOriginAttributes | SerializedLoadContext from child is null");
- return "SerializedLoadContext from child is null";
+ if (!UsingNeckoIPCSecurity()) {
+ if (!aSerialized.IsNotNull()) {
+ // If serialized is null, we cannot validate anything. We have to assume
+ // that this requests comes from a SystemPrincipal.
+ aAttrs = DocShellOriginAttributes(NECKO_NO_APP_ID, false);
+ } else {
+ aAttrs = aSerialized.mOriginAttributes;
}
+ return nullptr;
+ }
- // If serialized is null, we cannot validate anything. We have to assume
- // that this requests comes from a SystemPrincipal.
- aAttrs = DocShellOriginAttributes(NECKO_NO_APP_ID, false);
- return nullptr;
+ if (!aSerialized.IsNotNull()) {
+ CrashWithReason("GetValidatedOriginAttributes | SerializedLoadContext from child is null");
+ return "SerializedLoadContext from child is null";
}
nsTArray<TabContext> contextArray =
static_cast<ContentParent*>(aContent)->GetManagedTabContext();
nsAutoCString serializedSuffix;
aSerialized.mOriginAttributes.CreateAnonymizedSuffix(serializedSuffix);
@@ -222,22 +226,16 @@ NeckoParent::GetValidatedOriginAttribute
if (swm &&
swm->MayHaveActiveServiceWorkerInstance(static_cast<ContentParent*>(aContent),
aRequestingPrincipal)) {
aAttrs = aSerialized.mOriginAttributes;
return nullptr;
}
}
- if (!UsingNeckoIPCSecurity()) {
- // We are running some tests
- aAttrs = aSerialized.mOriginAttributes;
- return nullptr;
- }
-
nsAutoCString errorString;
errorString.Append("GetValidatedOriginAttributes | App does not have permission -");
errorString.Append(debugString);
// Leak the buffer on the heap to make sure that it lives long enough, as
// MOZ_CRASH_ANNOTATE expects the pointer passed to it to live to the end of
// the program.
char * error = strdup(errorString.BeginReading());