Repository navigation
Fix use-after-free when an error handler replaces the ArrayObject backing store - #25469
Closed
nicolas-grekas wants to merge 1 commit into
Closed
nicolas-grekas wants to merge 1 commit into
nicolas-grekas wants to merge 1 commit into
Conversation
…king store spl_array_get_dimension_ptr(), spl_array_has_dimension_ex() and ArrayIterator::seek() fetch the backing HashTable before code that can call an error handler: get_hash_key() for float and resource offsets, the "Undefined array key" warnings of read-write accesses, and argument parsing. The handler can call exchangeArray() or __construct(), which frees the table that is then read or written. Fetch the table after that code instead, and look the key up again after the warning for an unset property of a backing object.
Contributor
Author
|
Let me close: this needs a global fix, see #20018. |
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.
An error handler can replace the backing store of an ArrayObject in the middle of an offset access. The table that was fetched before the error is then used after it's freed:
It's the same for
isset($ao[1.5]), for$ao->b .= 'x'on a missing key withARRAY_AS_PROPS, and forArrayIterator::seek(1.5)when the handler calls__construct().This PR fetches the table after the code that can call the handler.