Skip to content

Commit

Permalink
Don't attempt to interpret wrongly sized data
Browse files Browse the repository at this point in the history
  • Loading branch information
SquareMan committed Oct 15, 2024
1 parent 462453c commit d676972
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions objdiff-core/src/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,9 @@ pub enum DataType {

impl DataType {
pub fn display_bytes<Endian: ByteOrder>(&self, bytes: &[u8]) -> Option<String> {
let Some(required_len) = self.required_len() else {
if self.required_len().is_some_and(|l| bytes.len() != l) {
return None;
};
// TODO: For symbols larger than their data type, we should probably support
// using the relocation's relative offset to read the bytes.
let bytes = bytes.get(0..required_len)?;
}

match self {
DataType::Int8 => {
Expand Down

0 comments on commit d676972

Please sign in to comment.