Skip to content

lz4io: --list: block sizes bounded as by the decoder - #2044

Closed
b84330808 wants to merge 1 commit into
lz4:devfrom
b84330808:list-block-size-bounds
Closed

b84330808 wants to merge 1 commit into
lz4:devfrom
b84330808:list-block-size-bounds

Conversation

@b84330808

Copy link
Copy Markdown

lz4 --list skips blocks without decoding them, but its size checks don't match the decoder's:

  • LZ4 frame: a block larger than the frame's maximum block size is skipped, so the frame is listed as valid while lz4 -t fails with maxBlockSize_invalid. Where long is 32-bit (Windows, 32-bit targets), a block size near 2 GB also takes nextBlock to LONG_MAX: the assert() fails in debug builds (Assertion failed: nextBlock < LONG_MAX), and release builds seek backward.
  • Legacy frame: blocks were limited to 8 MB, but a block of incompressible data is larger (the decoder accepts up to LZ4_COMPRESSBOUND(8 MB)), so --list rejected valid files made by lz4 -l ("Corrupted legacy frame").
  • Legacy frame: a truncated block was skipped with fseek() past the end of the file, so the frame was listed as valid. It now uses fseek_u32(), which reads the block's last byte, as for skippable frames (lz4io: detect truncated skippable frames in regular files #1914).

Tests extend test-lz4-basic.sh and test-lz4-multiple-legacy.sh; both fail without the lz4io.c change. The NEWS change only adds a name to the existing --list line.

--list skips blocks without decoding them, but its size checks didn't
match the decoder's :

- a block of an LZ4 frame larger than the frame's maximum block size
  was skipped, so such a frame was listed as valid while `lz4 -t`
  rejects it (maxBlockSize_invalid). Where long is 32-bit (Windows,
  32-bit targets), a block size near 2 GB also made `nextBlock` reach
  LONG_MAX : assert() failure in debug builds, negative seek otherwise.
- a legacy block was limited to 8 MB, but blocks of incompressible data
  are larger (up to LZ4_COMPRESSBOUND(8 MB), as accepted by the
  decoder) : --list rejected valid files made by `lz4 -l`.
- a truncated legacy block was skipped with fseek() past the end of
  the file, so the frame was listed as valid. fseek_u32() reads the
  block's last byte, as for skippable frames.

Tests in test-lz4-basic.sh and test-lz4-multiple-legacy.sh.
b84330808 added a commit to b84330808/b84330808 that referenced this pull request Nov 5, 2026
A closed, unmerged PR also counts as landed when it was closed by a
merged pull request whose commits include one authored by me (the
maintainer picked my commit into their PR, e.g. lz4/lz4#2044 closed
by lz4/lz4#2050).
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