Skip to content

fix(lib): reject blocks with trailing bytes in RLE sections - #511

Merged
hellobertrand merged 1 commit into
mainfrom
fix/rle-trailing-bytes
Oct 13, 2026
Merged

hellobertrand merged 1 commit into
mainfrom
fix/rle-trailing-bytes

Conversation

@hellobertrand

@hellobertrand hellobertrand commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Ensure strict validation of RLE literal sections by verifying that both the read and write pointers reach their respective expected ends. This prevents potential issues where malformed data containing trailing bytes could be improperly accepted by the decoder.

Includes a new test case to verify that such forged blocks are correctly rejected.

Signed-off-by: Bertrand Lebonnois 5901952+hellobertrand@users.noreply.github.com

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of corrupted compressed data. Blocks with extra or missing RLE literal bytes, including unexpected literal data for an empty output, are now rejected instead of being decoded as valid. This helps prevent malformed data from being silently accepted.

Ensure strict validation of RLE literal sections by verifying that both the read and write pointers reach their respective expected ends. This prevents potential issues where malformed data containing trailing bytes could be improperly accepted by the decoder.

Includes a new test case to verify that such forged blocks are correctly rejected.

Signed-off-by: Bertrand Lebonnois <5901952+hellobertrand@users.noreply.github.com>
@hellobertrand hellobertrand added the bug Something isn't working label Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Oct 13, 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: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 927a678f-0329-4053-84c2-6d246215aedc
📥 Commits

Reviewing files that changed from the base of the PR and between fdad29c and 749ee4d.

📒 Files selected for processing (4)
  • src/lib/zxc_decompress.c
  • tests/test_common.h
  • tests/test_format.c
  • tests/test_main.c

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

📝 Walkthrough

GLO RLE decoding now rejects literal streams that leave encoded bytes unconsumed, including nonempty streams when no literals are required. A format regression test verifies that a trailing byte causes ZXC_ERROR_CORRUPT_DATA.

Changes: GLO RLE validation

Layer / File(s) Summary
Decoder validation and regression test
src/lib/zxc_decompress.c, tests/test_format.c, tests/test_common.h, tests/test_main.c
The decoder rejects RLE literal streams that do not consume the complete input. The registered regression test adds a trailing byte to a literal section and checks that decoding returns ZXC_ERROR_CORRUPT_DATA.

Priority: ⬇️ Low

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 749ee

The RLE validation change is mergeable after normal checks.

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 and concisely describes the main change: rejecting blocks with trailing bytes in RLE sections.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 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.

@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@hellobertrand

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hellobertrand
hellobertrand merged commit 0ff5205 into main Oct 13, 2026
100 checks passed
@hellobertrand
hellobertrand deleted the fix/rle-trailing-bytes branch October 13, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant