Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/object/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ impl KernelObjectContent {
return false;
}

// Need at least the e_ident fields read below (EI_CLASS, EI_DATA, EI_VERSION).
if self.bytes.len() < 7 {
return false;
}

// Byte 5: EI_CLASS, 0x1 = 32-bit, 0x2 = 64-bit module
if self.bytes[4] != 1 && self.bytes[4] != 2 {
return false;
Expand Down
6 changes: 4 additions & 2 deletions src/signature/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ impl RawKernelObjectSignature {
let header = bytemuck::try_pod_read_unaligned::<RawKernelObjectSignatureHeader>(header)
.map_err(Error::DataDecodeError)?;
let signature_length = header.signature_length() as usize;
let total_length =
signature_length + header.signer_length as usize + header.key_id_length as usize;
let total_length = signature_length
+ header.signer_length as usize
+ header.key_id_length as usize
+ size_of::<RawKernelObjectSignatureHeader>();
if signature_length == 0 || (total_length > before_magic.len()) {
return Ok(Some(RawKernelObjectSignature {
header,
Expand Down
Loading