Bug 435151 - XPCSafeJSObjectWrapper's construct hook was not correct. r+sr=jst

This commit is contained in:
Blake Kaplan 2009-02-25 17:32:23 -08:00
parent 14658eb0ed
commit 086c266705
2 changed files with 29 additions and 6 deletions

View File

@ -1013,15 +1013,12 @@ XPC_XOW_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
return JS_FALSE;
}
JSObject *callee = JSVAL_TO_OBJECT(argv[-2]);
NS_ASSERTION(GetWrappedObject(cx, callee), "How'd we get here?");
callee = GetWrappedObject(cx, callee);
if (!JS_CallFunctionValue(cx, obj, OBJECT_TO_JSVAL(callee), argc, argv,
if (!JS_CallFunctionValue(cx, obj, OBJECT_TO_JSVAL(wrappedObj), argc, argv,
rval)) {
return JS_FALSE;
}
return XPC_XOW_RewrapIfNeeded(cx, callee, rval);
return XPC_XOW_RewrapIfNeeded(cx, wrappedObj, rval);
}
static JSBool

View File

@ -79,6 +79,10 @@ JSBool
XPC_SJOW_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
jsval *rval);
static JSBool
XPC_SJOW_Create(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
jsval *rval);
static JSBool
XPC_SJOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
@ -195,7 +199,7 @@ JSExtendedClass sXPC_SJOW_JSClass = {
XPC_SJOW_Enumerate, (JSResolveOp)XPC_SJOW_NewResolve,
XPC_SJOW_Convert, XPC_SJOW_Finalize,
nsnull, XPC_SJOW_CheckAccess,
XPC_SJOW_Call, XPC_SJOW_Construct,
XPC_SJOW_Call, XPC_SJOW_Create,
nsnull, nsnull,
nsnull, nsnull
},
@ -948,6 +952,28 @@ XPC_SJOW_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
return JS_TRUE;
}
static JSBool
XPC_SJOW_Create(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
jsval *rval)
{
JSObject *callee = JSVAL_TO_OBJECT(argv[-2]);
NS_ASSERTION(GetUnsafeObject(callee), "How'd we get here?");
JSObject *unsafeObj = GetUnsafeObject(callee);
// Check that the caller can access the unsafe object.
if (!CanCallerAccess(cx, unsafeObj)) {
// CanCallerAccess() already threw for us.
return JS_FALSE;
}
if (!JS_CallFunctionValue(cx, obj, OBJECT_TO_JSVAL(callee), argc, argv,
rval)) {
return JS_FALSE;
}
return WrapJSValue(cx, callee, *rval, rval);
}
static JSBool
XPC_SJOW_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
{