Repository navigation
[DeepClone] Report malformed payloads like the extension - #718
Merged
Merged
Conversation
nicolas-grekas
added a commit
to symfony/php-ext-deepclone
that referenced
this pull request
Oct 14, 2026
…l#717 (nicolas-grekas) This PR was merged into the main branch. Discussion ---------- Fix deepclone_from_array() issues reported in symfony/polyfill#717 Reported in symfony/polyfill#717, which gets the polyfill side in symfony/polyfill#718. - The wakeup flags of `"objectMeta"` were read as 32-bit integers, so `4294967295` read as `-1` and `-4294967296` as no flag. Only their sign matters now. - When `deepclone_from_array()` returns lazy ghosts, it checks the markers of their properties and states right away, like for other objects. Unknown object or ref ids, values of the wrong type and malformed closures were reported on first access before. What depends on the code, eg a function or an enum case that doesn't exist, still fails on first access. - A negative closure index of a const-expr closure is reported before its class is looked up, like its other malformed parts. The most common marker, an object id, is checked inline: `deepclone_from_array()` of 1000 objects holding closures runs 1.5% fewer instructions. Commits ------- 178e0f2 Fix deepclone_from_array() issues reported in symfony/polyfill#717
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.
The extension gets its side in symfony/php-ext-deepclone#64.
__unserialize()can create, eg aHashContext, can be referenced before its state is replayed. A missing or malformed state is now reported instead of "unknown object id".TypeErrorof__unserialize(), without mentioning DeepClone.php.@silenced it, but Symfony's ErrorHandler still logged it."objectMeta"indexes at their first NUL byte. The closure index of a const-expr closure is checked before its site, like in the extension.I didn't check the scope of each object of a property (item 1 of the issue). That costs 3% on
deepclone_from_array(), for payloads thatdeepclone_to_array()never produces. I left the order of the checks (item 5) and the extra warning ofunserialize()(item 8) as is too. Both sides reject these payloads.