Skip to content

match: bound aligned_i by s->count - #1133

Merged
steadytao merged 1 commit into
RsyncProject:masterfrom
seks99x:fix-aligned-overflow
Oct 19, 2026
Merged

steadytao merged 1 commit into
RsyncProject:masterfrom
seks99x:fix-aligned-overflow

Conversation

@seks99x

@seks99x seks99x commented Oct 16, 2026

Copy link
Copy Markdown
Member

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.

Comment thread testsuite/aligned_overflow_test.py Outdated
@steadytao steadytao changed the title match: Bound aligned_i by s->count in hash_search() (--inplace) match: bound aligned_i by s->count 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
seks99x force-pushed the fix-aligned-overflow branch from 98b859e to eea59f9 Compare October 17, 2026 19:41
@steadytao
steadytao merged commit 9dc0ff6 into RsyncProject:master Oct 19, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants