Repository navigation
match: bound aligned_i by s->count - #1133
Merged
Merged
Conversation
steadytao
requested changes
Oct 17, 2026
When updating_basis_file is active (--inplace), hash_search() advances aligned_offset by s->blength and increments the 32-bit signed counter aligned_i until aligned_offset catches up to offset. If the source file is larger than 2 GiB and the peer supplies a small s->blength and s->count, continuing to increment aligned_i past s->count serves no purpose (as no basis blocks exist beyond s->count - 1) and can overflow INT32_MAX into a negative index that bypasses the one-sided aligned_i < s->count check. Stop the catch-up loop once aligned_i reaches s->count so aligned_i remains strictly within [0, s->count] and cannot overflow. Reported-by: Mominul Islam Hemal <mominulislam-2021411216@cs.du.ac.bd>
seks99x
force-pushed
the
fix-aligned-overflow
branch
from
October 17, 2026 19:41
98b859e to
eea59f9
Compare
steadytao
approved these changes
Oct 19, 2026
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.
When updating_basis_file is active (--inplace), hash_search() advances aligned_offset by s->blength and increments the 32-bit signed counter aligned_i until aligned_offset catches up to offset.
If the source file is larger than 2 GiB and the peer supplies a small s->blength and s->count, continuing to increment aligned_i past s->count serves no purpose (as no basis blocks exist beyond s->count - 1) and can overflow INT32_MAX into a negative index that bypasses the one-sided aligned_i < s->count check.
Stop the catch-up loop once aligned_i reaches s->count so aligned_i remains strictly within [0, s->count] and cannot overflow.
Many thanks to @Hemalv02 for reporting.