[56_maintenance] Prevent buffer builder length overflow in MutableBuffer::extend_zeros (#9820)#9915
Merged
Merged
Conversation
11 tasks
…s` (apache#9820) - None. BufferBuilder reserve paths relied on unchecked usize arithmetic when calculating the required byte length. In optimized builds, very large requested lengths could wrap before capacity growth. This adds checked arithmetic for MutableBuffer byte length calculations used by reserve and zero-extension paths. Yes. This adds regression coverage for overflowing BufferBuilder length calculations through reserve, append_n_zeroed, and advance. Invalid requested lengths whose byte size cannot be represented without overflow now panic consistently. There are no API changes.
etseidl
approved these changes
May 6, 2026
|
|
||
| /// Allocates a new [MutableBuffer] with `len` and capacity to be at least `len` where | ||
| /// all bytes are guaranteed to be `0u8`. | ||
| /// |
Contributor
There was a problem hiding this comment.
Will this be forward ported? 😂
Contributor
Author
There was a problem hiding this comment.
🦅 👁️
I guess Codex couldn't resist. I will resist my personal temptation to actually forward port it to avoid needlessly burning carbon. Though it would help pump up my github stats 🙄 (though now with the AI tools those metrics are much less informative 🤔 )
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.
56.2.1(May 2026) #9857This PR:
MutableBuffer::extend_zeros#9820 from @alamb to the56_maintenanceline