Skip to content

Commit

Permalink
pe: fix unbound access to bytes slice at im pe/debug.rs:172
Browse files Browse the repository at this point in the history
  • Loading branch information
anfedotoff authored Sep 12, 2022
1 parent f9c3448 commit cb19f3b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/pe/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,18 @@ impl<'a> CodeviewPDB70DebugInfo<'a> {
let mut signature: [u8; 16] = [0; 16];
signature.copy_from_slice(bytes.gread_with(&mut offset, 16)?);
let age: u32 = bytes.gread_with(&mut offset, scroll::LE)?;
let filename = &bytes[offset..offset + filename_length];

Ok(Some(CodeviewPDB70DebugInfo {
codeview_signature,
signature,
age,
filename,
}))
if let Some(filename) = bytes.get(offset..offset + filename_length) {
Ok(Some(CodeviewPDB70DebugInfo {
codeview_signature,
signature,
age,
filename,
}))
} else {
Err(error::Error::Malformed(format!(
"ImageDebugDirectory seems corrupted: {:?}",
idd
)))
}
}
}

0 comments on commit cb19f3b

Please sign in to comment.