ext/standard: reject a dechunk chunk size that overflows size_t#22786
Open
iliaal wants to merge 1 commit into
Open
ext/standard: reject a dechunk chunk size that overflows size_t#22786iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
php_dechunk() accumulated the hex chunk size with chunk_size * 16 + digit and never checked the multiply, so a size of 2^64 wrapped to 0. A zero size reads as the terminating chunk, so the filter stopped there and dropped the body it had been handed. Error out instead, as the other malformed-size cases already do.
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.
php_dechunk()accumulated the hex chunk size withchunk_size * 16 + digitand never checked the multiply. A size of10000000000000000is 2^64, which wraps to 0, and 0 reads as the terminating chunk, so the filter stops and drops the body it was handed:The guard is hoisted out of the three digit branches rather than repeated in each, which needs the digit value computed first.
SIZE_MAX / 16is sufficient for the add as well: the largest value that survives it isSIZE_MAX / 16, andSIZE_MAX / 16 * 16 + 15is exactlySIZE_MAX.