Commit d3b77056 authored by mrbkap@gmail.com's avatar mrbkap@gmail.com
Browse files

Allow chrome files to touch implicit XPCNativeWrappers. bug 387084, r+sr=jst

parent 4786dc1f
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -237,6 +237,21 @@ EnsureLegalActivity(JSContext *cx, JSObject *obj)
    return JS_TRUE;
  }

  XPCCallContext ccx(JS_CALLER, cx);
  nsIXPCSecurityManager *sm = ccx.GetXPCContext()->
    GetAppropriateSecurityManager(nsIXPCSecurityManager::HOOK_CALL_METHOD);
  nsCOMPtr<nsIScriptSecurityManager> ssm(do_QueryInterface(sm));

  // A last ditch effort to allow access: if the subject principal is
  // the system principal, then some XPCNativeWrapper-using code has
  // passed one into other code. If that other code is chrome, then
  // allow access.
  PRBool isSystem;
  nsresult rv = ssm->SubjectPrincipalIsSystem(&isSystem);
  if (NS_SUCCEEDED(rv) && isSystem) {
    return JS_TRUE;
  }

  // Otherwise, we're looking at a non-system file with a handle on an
  // implicit wrapper. This is a bug! Deny access.
  return ThrowException(NS_ERROR_XPC_SECURITY_MANAGER_VETO, cx);