-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Out-of-bounds TypedArrays should be rejected #40
Comments
Can you take a look at #36?
Accepting detached buffers is intentional; it matches TextEncoder's x = new Uint8Array(10);
postMessage(null, '*', [x.buffer]); // detach x.buffer
console.log((new TextEncoder).encodeInto('xyz', x)); // read: 0, written: 0 I would usually prefer to match |
encodeInto doesn't seem to specify how detached and out-of-bounds resizable TypedArrays are handled:
|
Hm, yeah, it seems you're right that detached buffers are underspecified. I have whatwg/webidl#1385 to track. But in all three major engines, x = new Uint8Array(10);
postMessage(null, '*', [x.buffer]); // detach x.buffer
console.log((new TextEncoder).encodeInto('xyz', x)); prints "read: 0, written: 0", so it seems that web reality is to treat them as zero-length. Resizable buffers are rejected by |
I don't know if it's necessary to accept detached buffers just to match
This was confusing to me, because it explicitly mentioned detached or shrunk buffers, but didn't check for that state before
|
The new functions should probably all call
ValidateTypedArray(O, seq-cst)
to ensure out-of-bounds TypedArrays are rejected. For exampleUint8Array.fromBase64Into
currently silently treats detached (and resizable out-of-bounds) TypedArrays as zero-length TypedArrays.Also
GetUint8ArrayBytes
doesn't seem to work correctly when the input is a resizable TypedArray, because it directly reads[[ArrayLength]]
instead of callingTypedArrayLength
.The text was updated successfully, but these errors were encountered: