Skip to content

vmm: Fix bzip2 magic header detection#622

Open
d-e-s-o wants to merge 1 commit intocontainers:mainfrom
d-e-s-o:topic/fix-bz2-windows
Open

vmm: Fix bzip2 magic header detection#622
d-e-s-o wants to merge 1 commit intocontainers:mainfrom
d-e-s-o:topic/fix-bz2-windows

Conversation

@d-e-s-o
Copy link
Copy Markdown
Contributor

@d-e-s-o d-e-s-o commented Apr 8, 2026

The bzip2 magic byte search uses .windows(4) to produce 4-byte slices, but compares them against the 3-byte pattern [b'B', b'Z', b'h']. As a result, we will never see a match. Thus, the bzip2 header is never found, and loading always fails with ImageBz2Invalid (surfacing as EINVAL to callers).
Fix the issue by using .windows(3), matching how the gzip path handles its 3-byte magic.

The bzip2 magic byte search uses .windows(4) to produce 4-byte slices,
but compares them against the 3-byte pattern [b'B', b'Z', b'h']. As a
result, we will never see a match. Thus, the bzip2 header is never
found, and loading always fails with ImageBz2Invalid (surfacing as
EINVAL to callers).
Fix the issue by using .windows(3), matching how the gzip path handles
its 3-byte magic.

Signed-off-by: Daniel Müller <deso@posteo.net>
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