Repository navigation
Conversation
… process Assigning to a string offset past the end of the string extends it to the offset with a non-fallible allocation. As the offset is user controlled, it can ask for any size, and once that size exceeds the hard memory limit (twice memory_limit), the process gets killed right away, without running shutdown functions. Extend the string with a fallible allocation instead, like str_repeat() and str_pad() do for their user controlled sizes. If the memory limit doesn't allow the new size, the string is left untouched and the regular "Allowed memory size exhausted" fatal error is raised, so shutdown functions run as usual. This applies to the VM and the JIT helper alike.
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.
Assigning to a string offset past the end of the string extends the string up to that offset with a non-fallible allocation. The offset is user controlled, so it can ask for any size. Since #25626, such an assignment kills the process once the size exceeds twice
memory_limit, without running shutdown functions:Before
This PR
This uses
zend_string_fextend()withfallible = trueinzend_assign_to_string_offset()of both the VM and the JIT helper. It's the same approachstr_repeat()andstr_pad()already use for their user controlled sizes. If the memory limit doesn't allow the new size, the string is left untouched and the regular delayed out of memory error is raised.