Bug 1315905 - Cleanup Necko http security check, r=valentin
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 25 Nov 2016 10:53:59 +0100
changeset 324312 369bbb5eb097686bf21099e7b8f872e37c5b227e
parent 324311 08cbfe9c9060505ef904b744ada975a65ec9ca73
child 324313 11c4b40810daba7ecf6153b83cfa7a102be75575
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersvalentin
bugs1315905
milestone53.0a1
Bug 1315905 - Cleanup Necko http security check, r=valentin
netwerk/ipc/NeckoParent.cpp
--- a/netwerk/ipc/NeckoParent.cpp
+++ b/netwerk/ipc/NeckoParent.cpp
@@ -154,26 +154,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);
 
@@ -208,22 +212,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());