Skip to content

fix: LZ4 block compressor/decompressor safety issues - #344

Merged
lxy-9602 merged 4 commits into
alibaba:mainfrom
lxy-9602:fix-lz-compress
Jun 8, 2026
Merged

fix: LZ4 block compressor/decompressor safety issues#344
lxy-9602 merged 4 commits into
alibaba:mainfrom
lxy-9602:fix-lz-compress

Conversation

@lxy-9602

@lxy-9602 lxy-9602 commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Purpose

No Linked issue.

  • Decompressor: Add src_length < HEADER_LENGTH guard before ReadIntLE to prevent out-of-bounds read on truncated/corrupted blocks.
  • Compressor: Change compressed_size < 0 to <= 0 since LZ4_compress_default returns 0 (not negative) on failure, which previously produced silent corrupt blocks.

Tests

  • TestDecompressTruncatedHeader: Verifies truncated input (3 bytes / 0 bytes) returns Invalid instead of reading out-of-bounds.
  • TestCompressInsufficientOutputBuffer: Verifies insufficient output buffer returns error instead of writing a corrupt block.

API and Format

Documentation

Generative AI tooling

@zjw1111 zjw1111 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the latest head and the previous LZ4 output-buffer issue is fixed. No remaining actionable issues from my side.

@lxy-9602
lxy-9602 merged commit 62e3794 into alibaba:main Jun 8, 2026
9 checks passed
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.

2 participants