Ignore pathologically large depths longer than strlen#67
Merged
crazyxman merged 2 commits intocrazyxman:masterfrom Oct 1, 2022
Merged
Ignore pathologically large depths longer than strlen#67crazyxman merged 2 commits intocrazyxman:masterfrom
crazyxman merged 2 commits intocrazyxman:masterfrom
Conversation
Closes crazyxman#66 For example, for `simdjson_decode('{}', true, 1000000000)`, we only need a depth that's at least 2 to get identical results. PHP programmers may assume that a large depth is a safe way to avoid depth errors because it was safe for `json_decode` To avoid allocating too much virtual memory and wasting page table entries or potentially fatal out of memory errors, reduce depth to a safe value behaving the same way if the requested depth is larger than the allocated depth, larger than the string length, and exceeds 100000. Do this in a way that reduces reallocations.
Collaborator
Author
|
I expect 2.0.4 to be released tomorrow at the earliest, if it's approved by then |
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.
Closes #66
For example, for parsing strings shorter than the depth, e.g.
simdjson_decode('{}', true, 1000000000), we only need a depth that's at leaststrlen('{}') === 2to get identical results for invalid json.PHP programmers may assume that a large depth is a safe way to avoid depth errors because it was safe for
json_decodeTo avoid allocating too much virtual memory and wasting page table entries or potentially fatal out of memory errors, reduce depth to a safe value behaving the same way if the requested depth is larger than the allocated depth, larger than the string length, and exceeds 100000.
Do this in a way that reduces reallocations.