Skip to content

fix: detect legacy lz4 frames from their signature - #1106

Open
b84330808 wants to merge 1 commit into
ouch-org:mainfrom
b84330808:fix/lz4-legacy-signature
Open

b84330808 wants to merge 1 commit into
ouch-org:mainfrom
b84330808:fix/lz4-legacy-signature

Conversation

@b84330808

Copy link
Copy Markdown

Fixes #1104

Files made with lz4 -l (the legacy frame format, used for Linux kernel images) start with the magic number 0x184C2102. lz4_flex already decodes them, but try_infer_format only checked for the current frame magic 0x184D2204. So without an .lz4 extension ouch refused the file, and with one it printed "Failed to confirm the format ... file might be misnamed".

This adds the legacy magic to is_lz4 (lz4 frame format spec, "Legacy frame"). I didn't add 0x184C2103 from the issue: it isn't in the spec and lz4_flex can't decode it.

Tests: a unit test for the signature, and an integration test that decompresses a legacy frame with no extension.

I used Claude Code to write this change.

Files written in the legacy lz4 frame format (`lz4 -l`, used for Linux
kernel images) start with the magic number 0x184C2102. lz4_flex already
decodes them, but the signature check only knew the current frame magic,
so these files were not recognized without an `.lz4` extension.

Fixes ouch-org#1104

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@mvastola mvastola left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good if tests pass

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.

LZ4 file signatures undetected

2 participants