Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit d8ab05d

Browse files
committed
Fix issue discovered by honggfuzzGptHeader::header_size is supposed to between, inclusive, 92 and the logical block size.Slice indexing goes out of range and panics if this isn't checked.Also check that it's enough for our GptHeader struct.
1 parent 2a9e14a commit d8ab05d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: src/gpt.rs

+7
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ fn check_validity<RS: Read + Seek>(
7878
block_size: u64,
7979
) -> Result<(), InnerError> {
8080
ensure!(header.signature == EFI_PART, Signature);
81+
ensure!(header.header_size >= 92, InvalidGptHeader);
82+
// FIXME: This one shouldn't be a requirement.
83+
ensure!(
84+
header.header_size <= std::mem::size_of::<GptHeader>() as u32,
85+
InvalidGptHeader
86+
);
87+
ensure!(header.header_size <= block_size as u32, InvalidGptHeader);
8188
let old_crc = std::mem::replace(&mut header.header_crc32, 0);
8289
let crc = calculate_crc(header);
8390
header.header_crc32 = old_crc;

0 commit comments

Comments
 (0)