Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

TypedArrays: Fix size/index overflow on 32-bit. #4550

Closed
wants to merge 5 commits into from

Conversation

deanm
Copy link

@deanm deanm commented Jan 9, 2013

Depends on #4547

This seems to have been added as a result of misreading the spec, there is no
get() method, only a getter (which the spec names get()), but this is actually
the [] operator.  There are many webkit tests that explicitly test for the
fact that the get() method is abscent.  Remove it to conform to the spec.
It seems that like get(), set(index, val) was added as a misreading of the spec.
There are only two set() methods defined in the spec:
    void set(TypedArray array, optional unsigned long offset)
    void set(type[] array, optional unsigned long offset)
The set(index, val) is handled by the []= operator.
Additionally updated a few exception error strings to match WebKit.
On 64-bit, the calculation is promoted to a 64-bit int.  However on 32-bit the
int will be 32-bit and the index + size calculation can overflow.  Rearrange
the math to prevent overflow and add a few more checks for additional safety.
The size should never be less than 0, for example, but we check anyway.
@bnoordhuis
Copy link
Member

For posterity, this PR doesn't apply to v0.8 so I've landed a fix for the overflow bug in ed825f4.

@deanm
Copy link
Author

deanm commented Jan 10, 2013

Yeah, it depends on #4547. Perhaps I will make a future patch that cleans up overall some of the signed/unsigned-ness throughout the code. A bit awkward sometimes between the V8 api and the TypedArray spec.

Thanks for patching it against 0.8.

@Nodejs-Jenkins
Copy link

Can one of the admins verify this patch?

@tjfontaine
Copy link

We now use typed arrays directly from V8, thanks!

@tjfontaine tjfontaine closed this Feb 18, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants