Skip to content

fix(ext/napi): check napi_create_typedarray length overflow - #36991

Open
isl-Ramzi wants to merge 1 commit into
denoland:mainfrom
isl-Ramzi:napi-typedarray-overflow-check
Open

isl-Ramzi wants to merge 1 commit into
denoland:mainfrom
isl-Ramzi:napi-typedarray-overflow-check

Conversation

@isl-Ramzi

Copy link
Copy Markdown

napi_create_typedarray checks the view fits its ArrayBuffer with length * soe + byte_offset > ab.byte_length(), but the multiply and the add overflow usize for a large length, so the comparison wraps back under the bound (and panics under debug overflow checks) and the bogus length is handed to V8. This is the same overflow #36962 just fixed for napi_create_dataview, so I used the matching checked_mul/checked_add form here and added typedarray regression tests next to the dataview ones.

AI tooling was used to help prepare this change.

This branch has not been deployed

No deployments
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.

1 participant