diff --git a/src/backup/image_index.rs b/src/backup/image_index.rs index 8eabf547..d2aed5d6 100644 --- a/src/backup/image_index.rs +++ b/src/backup/image_index.rs @@ -51,13 +51,22 @@ impl <'a> ImageIndexReader<'a> { let header_size = std::mem::size_of::(); // todo: use static assertion when available in rust - if header_size != 4096 { panic!("got unexpected header size"); } + if header_size != 4096 { bail!("got unexpected header size for {:?}", path); } let mut buffer = vec![0u8; header_size]; file.read_exact(&mut buffer)?; let header = unsafe { &mut * (buffer.as_ptr() as *mut ImageIndexHeader) }; + if header.magic != *b"PROXMOX-IIDX" { + bail!("got unknown magic number for {:?}", path); + } + + let version = u32::from_be(header.version); + if version != 1 { + bail!("got unsupported version number ({})", version); + } + let size = u64::from_be(header.size) as usize; let ctime = u64::from_be(header.ctime); let chunk_size = u64::from_be(header.chunk_size) as usize;