Bug 751858 - Actually throw when we deny access. r=bholley
authorBlake Kaplan <mrbkap@gmail.com>
Fri, 04 May 2012 14:22:55 +0200
changeset 100592 8d752d1b621b6e30abc8774387fc55fecdd370e0
parent 100591 b7fb3d52c8437f9f614430f2c40e50444c4e5b6f
child 100593 fe0b1390710fe16ffec29c85ca9174cfd45cb4cf
push idunknown
push userunknown
push dateunknown
reviewersbholley
bugs751858
milestone15.0a1
Bug 751858 - Actually throw when we deny access. r=bholley
js/xpconnect/wrappers/AccessCheck.cpp
js/xpconnect/wrappers/AccessCheck.h
--- a/js/xpconnect/wrappers/AccessCheck.cpp
+++ b/js/xpconnect/wrappers/AccessCheck.cpp
@@ -450,22 +450,20 @@ ExposedPropertiesOnly::check(JSContext *
                              Permission &perm)
 {
     JSObject *wrappedObject = Wrapper::wrappedObject(wrapper);
 
     if (act == Wrapper::CALL) {
         perm = PermitObjectAccess;
         return true;
     }
-    if (act == Wrapper::PUNCTURE) {
-        perm = DenyAccess;
-        return false;
-    }
 
     perm = DenyAccess;
+    if (act == Wrapper::PUNCTURE)
+        return PermitIfUniversalXPConnect(cx, id, act, perm); // Deny
 
     jsid exposedPropsId = GetRTIdByIndex(cx, XPCJSRuntime::IDX_EXPOSEDPROPS);
 
     JSBool found = false;
     JSAutoEnterCompartment ac;
     if (!ac.enter(cx, wrappedObject) ||
         !JS_HasPropertyById(cx, wrappedObject, exposedPropsId, &found))
         return false;
--- a/js/xpconnect/wrappers/AccessCheck.h
+++ b/js/xpconnect/wrappers/AccessCheck.h
@@ -115,24 +115,23 @@ struct LocationPolicy : public Policy {
                       Permission &perm) {
         // We should only be dealing with Location objects here.
         MOZ_ASSERT(WrapperFactory::IsLocationObject(js::UnwrapObject(wrapper)));
 
         // Default to deny.
         perm = DenyAccess;
 
         // Location object security is complicated enough. Don't allow punctures.
-        if (act == js::Wrapper::PUNCTURE)
-            return false;
-
-        if (AccessCheck::isCrossOriginAccessPermitted(cx, wrapper, id, act) ||
-            AccessCheck::isLocationObjectSameOrigin(cx, wrapper)) {
+        if (act != js::Wrapper::PUNCTURE &&
+            (AccessCheck::isCrossOriginAccessPermitted(cx, wrapper, id, act) ||
+             AccessCheck::isLocationObjectSameOrigin(cx, wrapper))) {
             perm = PermitPropertyAccess;
             return true;
         }
+
         JSAutoEnterCompartment ac;
         if (!ac.enter(cx, wrapper))
             return false;
         AccessCheck::deny(cx, id);
         return false;
     }
 };