Skip to content

fix(r2007): a zero back-reference offset is a malformed stream, not a panic - #291

Merged
DrunkOnJava merged 1 commit into
mainfrom
fix/r21-lz-zero-offset
Oct 26, 2026
Merged

DrunkOnJava merged 1 commit into
mainfrom
fix/r21-lz-zero-offset

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Fuzz nightly run 40317510812 on 6588c41 crashed dwg_file_open at src/r21_lz.rs:337 (index out of bounds). The R21 LZ back-reference copy reads out[out.len() - offset + i], so a decoded offset of 0 reads one past the end on its first byte. Offsets of 1 or more are safe, overlapping copies included, because each push grows out ahead of the read.

A real stream never encodes a zero distance, so the decoder now returns Lz77InvalidOffset for it. The crash input is added as fuzz/corpus/dwg_file_open/regress_r21_lz_zero_offset.bin, which tests/integration_fuzz_corpus_regression.rs replays through DwgFile.

Evidence:

  • Before the fix, dwg_file_open_corpus_no_panic panics at r21_lz.rs:337:28 on the new seed. After it, the replay suite passes (5/5).
  • Real-file suites on the 19-file corpus (samples, corpus_roundtrip, r2013_entity_values): 6, 15 and 23 passed, none skipped.
  • Public corpus: measure.py check reports "Every one of 52 rows matches", so no real R2007 stream changes.
  • cargo fmt --check and cargo clippy --all-targets -D warnings are clean.

… panic

The R21 LZ decoder computed start = out.len() - offset and read out[start + i];
an offset of 0 put start at out.len(), so the first read was out of bounds.
Fuzz nightly run 40317510812 (dwg_file_open) hit it at src/r21_lz.rs:337.
A real stream never encodes a zero distance, so it is now Lz77InvalidOffset.
The crash input joins fuzz/corpus/dwg_file_open as a replayed seed.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T12:26:27.363323Z 6c04bbf PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 26, 2026 12:30
@DrunkOnJava
DrunkOnJava merged commit b245d1b into main Oct 26, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/r21-lz-zero-offset branch October 26, 2026 12:38
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