Skip to content
Permalink
Browse files

Fix issue discovered by honggfuzz`GptHeader::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.
  • Loading branch information...
DianaNites committed Oct 2, 2019
1 parent 2a9e14a commit d8ab05d48d87814f362e94f01c93d9eeb4f4abf4
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/gpt.rs
@@ -78,6 +78,13 @@ fn check_validity<RS: Read + Seek>(
block_size: u64,
) -> Result<(), InnerError> {
ensure!(header.signature == EFI_PART, Signature);
ensure!(header.header_size >= 92, InvalidGptHeader);
// FIXME: This one shouldn't be a requirement.
ensure!(
header.header_size <= std::mem::size_of::<GptHeader>() as u32,
InvalidGptHeader
);
ensure!(header.header_size <= block_size as u32, InvalidGptHeader);
let old_crc = std::mem::replace(&mut header.header_crc32, 0);
let crc = calculate_crc(header);
header.header_crc32 = old_crc;

0 comments on commit d8ab05d

Please sign in to comment.
You can’t perform that action at this time.