Bug 957688 - Make ComputeStackString pass a principal and remove checkAccess call. r=mrbkap

Now that we have the principal-based filtering for stack walking, we can do this.
This isn't technically equivalent to the old behavior, since a stack that goes:

A -> B -> A

would previous have only seen the second set of |A| frames, whereas now we'd
see both sets. But this seems strictly better (also, it doesn't happen on the
web).

As noted, I've filed a bug for making this context- and saveFrameChain-agnostic.
This commit is contained in:
Bobby Holley 2014-01-24 16:08:24 -08:00
parent 07cf57140e
commit 83a7fd5f32

View File

@ -207,23 +207,18 @@ struct SuppressErrorsGuard
static JSString *
ComputeStackString(JSContext *cx)
{
JSCheckAccessOp checkAccess = cx->runtime()->securityCallbacks->checkObjectAccess;
StringBuffer sb(cx);
{
RootedAtom atom(cx);
SuppressErrorsGuard seg(cx);
for (NonBuiltinScriptFrameIter i(cx); !i.done(); ++i) {
// Cut off the stack if this callee crosses a trust boundary.
if (checkAccess && i.isNonEvalFunctionFrame()) {
RootedValue v(cx);
RootedId callerid(cx, NameToId(cx->names().caller));
RootedObject obj(cx, i.callee());
if (!checkAccess(cx, obj, callerid, JSACC_READ, &v))
break;
}
// We should get rid of the CURRENT_CONTEXT and STOP_AT_SAVED here.
// See bug 960820.
for (NonBuiltinScriptFrameIter i(cx, ScriptFrameIter::CURRENT_CONTEXT,
ScriptFrameIter::STOP_AT_SAVED,
cx->compartment()->principals);
!i.done(); ++i)
{
/* First append the function name, if any. */
atom = nullptr;
if (i.isNonEvalFunctionFrame() && i.callee()->displayAtom())