Skip to content
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

LibJS: Protect CanonicalIndex against double-to-integer overflow #16354

Merged
merged 3 commits into from
Dec 7, 2022

Conversation

trflynn89
Copy link
Member

Ref #16353

Diff Tests:
    test/built-ins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js  ❌ -> ✅
    test/built-ins/TypedArray/prototype/with/index-smaller-than-minus-length.js ❌ -> ✅

ErrorType::InvalidIndex does not encapsulate the reasons why an index
may be invalid. For example:

    let array = new Uint8Array([1, 2, 3, 4, 5]);
    array.with(10, 0);

Will currently yield:

    [RangeError] Index must be a positive integer

Which is misleading because 10 *is* a positive integer.
@trflynn89 trflynn89 added the 👀 pr-needs-review PR needs review from a maintainer or community member label Dec 7, 2022
Explicitly disallow constructing a CanonicalIndex from a floating point
type without going through a factory method that will throw when the
provided index cannot fit in a u32.
Copy link
Member

@linusg linusg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woohoo!

@linusg linusg added ✅ pr-maintainer-approved-but-awaiting-ci PR has been approved by a maintainer and can be merged after CI has passed and removed 👀 pr-needs-review PR needs review from a maintainer or community member labels Dec 7, 2022
@linusg linusg merged commit d37d6b3 into SerenityOS:master Dec 7, 2022
@linusg linusg removed the ✅ pr-maintainer-approved-but-awaiting-ci PR has been approved by a maintainer and can be merged after CI has passed label Dec 7, 2022
@trflynn89 trflynn89 deleted the js_index_overflow branch December 7, 2022 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants