[jsc-dev] Protect against modifying contents of `ArrayBuffer` in `JavaScriptCore`
Saam barati
sbarati at apple.com
Fri Oct 19 12:00:07 PDT 2018
Hi Karol,
What context are you running JavaScript code in?
Are you using the JavaScriptCore ObjC or C APIs? Something else?
- Saam
> On Oct 19, 2018, at 1:56 AM, Karol Szafranski <karolszafranski at gmail.com> wrote:
>
> `ArrayBuffer` is created in JavaScript engine, and reference is passed to the "native side":
>
>
> var myBuffer = new ArrayBuffer(32);
> protectBufferMemory(myBuffer);
>
>
> Now I would like to hide the contents of the `ArrayBuffer` from the JavaScript engine. It would be best if `ArrayBuffer` could suddenly return 0 for `byteLength`, stay empty and nonresizable when looking at it with any `TypedArray`.
>
> In the same time, I need to keep the contents of the `ArrayBuffer` in memory in the same place as it was. I do not want to copy those bytes.
>
> Note: this is exactly how `ArrayBuffer` behaves in Chrome when you `postMessage` to a `Worker` with `ArrayBuffer` instance in the "transfer" array.
>
> If there is no way of doing this, the following alternatives would also be acceptable:
>
> 1. Removing the `ArrayBuffer` instance from the JavaScript engine, so that all variables pointing to it will return `undefined` would also be acceptable. As long as data will not be removed from memory.
>
> 2. Keeping `ArrayBuffer` data visible inside JavaScript engine but disallow modification.
>
> Thank you very much in advance.
>
> Karol SzafraĆski
>
> _______________________________________________
> jsc-dev mailing list
> jsc-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/jsc-dev
More information about the jsc-dev
mailing list