Skip to content

Commit eaac662

Browse files
d-e-s-oslp
authored andcommitted
vmm: Fix bzip2 magic header detection
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 <[email protected]>
1 parent 44312fd commit eaac662

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/vmm/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ fn load_external_kernel(
11831183
let data: Vec<u8> = std::fs::read(external_kernel.path.clone())
11841184
.map_err(StartMicrovmError::ImageBz2OpenKernel)?;
11851185
if let Some(magic) = data
1186-
.windows(4)
1186+
.windows(3)
11871187
.position(|window| window == [b'B', b'Z', b'h'])
11881188
{
11891189
debug!("Found BZIP2 header on Image file at: 0x{magic:x}");

0 commit comments

Comments
 (0)