Skip to content

flate: Fix stateless EOF on large writes. - #1265

Merged
klauspost merged 1 commit into
masterfrom
flate-stateless-eof
Oct 14, 2026
Merged

klauspost merged 1 commit into
masterfrom
flate-stateless-eof

Conversation

@klauspost

@klauspost klauspost commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Fixes StatelessDeflate(w, data, true, dict) with non-empty data long enough to be split into more than one internal block (more than 32 KB, or about 24 KB with a dictionary) missing EOF blocks.

Reported by OSS-fuzz

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue that could produce invalid output when encoding a final Huffman-compressed block after a non-final block.
    • Improved round-trip reliability for streams containing consecutive Huffman blocks.

Fixes `StatelessDeflate(w, data, true, dict)` with non-empty data long enough to be split into more than one internal block (more than 32 KB, or about 24 KB with a dictionary) missing EOF blocks.

Reported by OSS-fuzz
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a7d7ab81-f6f1-4677-a7ff-9ecab9d28877
📥 Commits

Reviewing files that changed from the base of the PR and between f9c3428 and b173f5b.

⛔ Files ignored due to path filters: 1
  • flate/testdata/fuzz/encode-oss-corpus.zip is excluded by !**/*.zip
📒 Files selected for processing: 4
  • flate/fuzz_test.go
  • flate/huffman_bit_writer.go
  • flate/huffman_bit_writer_test.go
  • internal/fuzz/helpers.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The flate fuzz harness now includes an OSS-Fuzz corpus and decodes OSS-Fuzz inputs through a shared helper. The Huffman writer now replaces the existing table for a final block. A regression test checks the decoded output.

Changes: Flate encoding and fuzzing

Layer / File(s) Summary
OSS-Fuzz input handling
internal/fuzz/helpers.go, flate/fuzz_test.go
The fuzz helpers extract payloads from OSS-Fuzz inputs. FuzzEncoding adds the OSS-Fuzz seed corpus.
Final Huffman block handling
flate/huffman_bit_writer.go, flate/huffman_bit_writer_test.go
writeBlockHuff replaces the existing Huffman table for a final block. The regression test decodes two written blocks and checks the output against the original input.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to b173f

The regression inputs reach the fuzz target as intended, and no issue requiring correction before merge was identified.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: fixing missing EOF blocks in stateless deflate operations with large writes.
Docstring Coverage Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@klauspost
klauspost merged commit 6de8e38 into master Oct 14, 2026
92 checks passed
@klauspost
klauspost deleted the flate-stateless-eof branch October 14, 2026 12:03
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