From 49d3dd3a82c77d8b16b90f41cbe985d9764cc19b Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 14 Aug 2012 08:31:02 -0700 Subject: [PATCH] Bug 777628 - Do a Checked Unwrap in JS_WriteTypedArray. r=jorendorff --- dom/tests/mochitest/bugs/Makefile.in | 1 + dom/tests/mochitest/bugs/test_bug777628.html | 42 ++++++++++++++++++++ js/src/jsclone.cpp | 9 +++++ 3 files changed, 52 insertions(+) create mode 100644 dom/tests/mochitest/bugs/test_bug777628.html diff --git a/dom/tests/mochitest/bugs/Makefile.in b/dom/tests/mochitest/bugs/Makefile.in index 5e5b9b95507..d1cb7159af9 100644 --- a/dom/tests/mochitest/bugs/Makefile.in +++ b/dom/tests/mochitest/bugs/Makefile.in @@ -129,6 +129,7 @@ MOCHITEST_FILES = \ worker_bug743615.js \ test_bug750051.html \ test_bug755320.html \ + test_bug777628.html \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/dom/tests/mochitest/bugs/test_bug777628.html b/dom/tests/mochitest/bugs/test_bug777628.html new file mode 100644 index 00000000000..f272fcb3e55 --- /dev/null +++ b/dom/tests/mochitest/bugs/test_bug777628.html @@ -0,0 +1,42 @@ + + + + + + Test for Bug 743615 + + + + + +Mozilla Bug 777628 +

+ +
+
+
+ + diff --git a/js/src/jsclone.cpp b/js/src/jsclone.cpp index 8e111e37de1..0a957cf84f8 100644 --- a/js/src/jsclone.cpp +++ b/js/src/jsclone.cpp @@ -402,6 +402,15 @@ JS_WriteTypedArray(JSStructuredCloneWriter *w, jsval v) { JS_ASSERT(v.isObject()); RootedObject obj(w->context(), &v.toObject()); + + // If the object is a security wrapper, try puncturing it. This may throw + // if the access is not allowed. + if (obj->isWrapper()) { + JSObject *unwrapped = UnwrapObjectChecked(w->context(), obj); + if (!unwrapped) + return false; + obj = unwrapped; + } return w->writeTypedArray(obj); }