From 57001fe1d3189128c09be9e1db5aaba839239961 Mon Sep 17 00:00:00 2001 From: Blake Kaplan Date: Fri, 12 Jun 2009 14:38:05 -0700 Subject: [PATCH] Bug 441714 - Protect caps against SJOWs. r+sr=dveditz --- caps/src/nsScriptSecurityManager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/caps/src/nsScriptSecurityManager.cpp b/caps/src/nsScriptSecurityManager.cpp index 86e59b75f31..b0b4f0cad52 100644 --- a/caps/src/nsScriptSecurityManager.cpp +++ b/caps/src/nsScriptSecurityManager.cpp @@ -2105,6 +2105,15 @@ nsScriptSecurityManager::GetFunctionObjectPrincipal(JSContext *cx, nsresult *rv) { NS_PRECONDITION(rv, "Null out param"); + if (!JS_ObjectIsFunction(cx, obj)) + { + // Protect against pseudo-functions (like SJOWs). + nsIPrincipal *result = doGetObjectPrincipal(obj); + if (!result) + *rv = NS_ERROR_FAILURE; + return result; + } + JSFunction *fun = (JSFunction *) caps_GetJSPrivate(obj); JSScript *script = JS_GetFunctionScript(cx, fun);