Repository navigation
Conversation
A valueOf() callback on the start or end argument can shrink the array after the length and the range have been computed. The fast array paths then accessed the shrunk buffer with the stale range. fill: clamp the end of the range to the current array length. copyWithin: validate the source range as well as the target range before using the fast path, otherwise fall back to the generic path. Fixes jerryscript-project#5283 Fixes jerryscript-project#5282 Signed-off-by: Alexander Marzouca <333385283+Perennos@users.noreply.github.com> JerryScript-DCO-1.0-Signed-off-by: Alexander Marzouca 333385283+Perennos@users.noreply.github.com
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5283
Fixes #5282
Array.prototype.fillandArray.prototype.copyWithincompute their index range from the array length before callingvalueOf()on user-supplied arguments. If that callback shrinks a fast array, the fast paths use the stale range against the smaller buffer:fillwrites past the end (heap out-of-bounds write) andcopyWithinreads past the end (heap out-of-bounds read).Both bugs share the same cause, so one patch fixes them:
fill: clamp the end of the range to the fast array's current length.copyWithin: the fast path previously checked only the target range; it now checks the source range as well and falls back to the generic path if either is out of bounds.Tests: added
tests/jerry/regression-test-issue-5283.jsandtests/jerry/regression-test-issue-5282.jsfrom the issue reproducers. Both abort (assertion failure) on an unpatched debug build and pass with the fix.python3 tools/run-tests.py --jerry-tests --build-debugpasses with the fix (1231/1231), including the two new tests and the existingarray-prototype-fill.js.AI-assisted: drafted with an AI coding assistant; reproduced and tested locally before submitting.