Skip to content

Commit cd2c7bd

Browse files
committed
gen2: check magic value for directory entries
Signed-off-by: Daniel Maslowski <[email protected]>
1 parent ec7d0a1 commit cd2c7bd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/dir/gen2.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ impl Directory {
173173
return Err("cannot parse ME FW Gen 2 directory header".to_string());
174174
};
175175
let pos = man::MANIFEST_SIZE + HEADER_SIZE;
176+
let m = &data[pos..pos + 4];
177+
178+
if !m.eq(ENTRY_MAGIC_BYTES) {
179+
return Err(format!(
180+
"entry magic not found, got {m:02x?}, wanted {ENTRY_MAGIC_BYTES:02x?} ({ENTRY_MAGIC})"
181+
));
182+
}
183+
176184
let slice = &data[pos..];
177185
let Ok((r, _)) = Ref::<_, [Entry]>::from_prefix_with_elems(slice, count) else {
178186
return Err(format!(

0 commit comments

Comments
 (0)