Skip to content

fix(xcrush): off-by-one in forward match loop causes panic during compression#1293

Merged
Benoît Cortier (CBenoit) merged 3 commits into
masterfrom
copilot/fix-failing-fuzzing-job
May 21, 2026
Merged

fix(xcrush): off-by-one in forward match loop causes panic during compression#1293
Benoît Cortier (CBenoit) merged 3 commits into
masterfrom
copilot/fix-failing-fuzzing-job

Conversation

Copy link
Copy Markdown

Copilot AI commented May 20, 2026

The XCRUSH find_match_length forward loop used fm > buf_end instead of fm >= buf_end, allowing it to read one byte past the current block boundary (buf[history_offset + src_size]). This inflated match_length beyond the block, causing current_offset > self.history_offset in generate_output, and an integer underflow panic at:

let trailing_len = self.history_offset - current_offset; // underflow

LibFuzzer reports this as a crash (exit status 77). The fuzzer corpus input that triggers it is 131 bytes with algo_byte & 0x03 == 3 (Rdp61/XCRUSH) and sufficient repeated-byte content to produce within-block chunk matches on the first call.

Changes

  • xcrush/mod.rsfind_match_length: Change termination condition fm > buf_endfm >= buf_end so forward matching stops at the block boundary.
  • xcrush/mod.rsgenerate_output: Add debug_assert! + defensive Err return before the subtraction as belt-and-suspenders protection against future regressions in match generation.
  • Regression test: Add the fuzzer crash input as a binary fixture under test_data/fuzz_regression/bulk_round_trip/ so check_bulk_round_trip catches any recurrence.

Copilot AI and others added 2 commits May 20, 2026 16:59
Copilot AI changed the title [WIP] Fix failing GitHub Actions job Fuzzing bulk_round_trip fix(xcrush): off-by-one in forward match loop causes panic during compression May 20, 2026
@glamberson
Copy link
Copy Markdown
Contributor

Neat.

@CBenoit Benoît Cortier (CBenoit) marked this pull request as ready for review May 21, 2026 15:01
@CBenoit Benoît Cortier (CBenoit) enabled auto-merge (squash) May 21, 2026 15:01
@CBenoit Benoît Cortier (CBenoit) enabled auto-merge (squash) May 21, 2026 15:02
@CBenoit Benoît Cortier (CBenoit) merged commit 0dd7c94 into master May 21, 2026
20 of 21 checks passed
@CBenoit Benoît Cortier (CBenoit) deleted the copilot/fix-failing-fuzzing-job branch May 21, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants