Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@ychin
Copy link
Contributor

@ychin ychin commented Dec 8, 2025

No description provided.

@gitgitgadget-git
Copy link

There are issues in commit ebe839e:
xdiff: Remove invalid/no-op range checks in histogram diff
Prefixed commit message must be in lower case
Commit not signed off

@ychin ychin force-pushed the fix-xhistogram-bad-range-check branch 2 times, most recently from 914d0a3 to e925bea Compare December 8, 2025 22:27
Histogram diff algorithm specifies MAX_CNT and MAX_PTR as upper limits
for cnt and ptr (both unsigned int's). This does not work, because
MAX_CNT / MAX_PTR are set to be UINT_MAX. Less-than comparisons against
them will succeed by default, meaning that the XDL_MIN check is a
logical no-op and fails to protect against `rec->cnt + 1` overflowing.
Additionally, xdiff in general is not safe to use above the 32-bit
integer limit, and Git protects against that with a hard cap of ~1 GB
(MAX_XDIFF_SIZE), meaning the histogram algorithm should never see cnt /
ptr reach these limits to begin with.

Tracing the lineage of the histogram algorithm, this appears to be a
porting error when transcribing from HistogramDiffIndex.java from
Eclipse jgit. In the original implementation, MAX_CNT and MAX_PTR are
set to much lower limits due to details specific to that implementation
(bit fields), which aren't relevant to xdiff's implementation.

To fix this, remove both the checks and MAX_CNT / MAX_PTR, as they don't
serve a purpose.

Signed-off-by: Yee Cheng Chin <[email protected]>
@ychin ychin force-pushed the fix-xhistogram-bad-range-check branch from e925bea to 1d7d2c1 Compare December 9, 2025 01:12
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.

1 participant