Skip to content

Commit

Permalink
Fix edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
main-- committed Oct 5, 2017
1 parent 0dfc604 commit caa8bda
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/cfi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ impl<R: Reader> EhFrameHdr<R> {
let eh_frame_ptr_enc = DwEhPe(reader.read_u8()?);
let fde_count_enc = DwEhPe(reader.read_u8()?);
let table_enc = DwEhPe(reader.read_u8()?);

// Omitting this pointer is not valid (defeats the purpose of .eh_frame_hdr entirely)
if eh_frame_ptr_enc == constants::DW_EH_PE_omit {
return Err(Error::UnexpectedNull);
}

let eh_frame_ptr = parse_encoded_pointer(eh_frame_ptr_enc, bases, addr_size, &self.0, &mut reader)?;
let fde_count = parse_encoded_pointer(fde_count_enc, bases, addr_size, &self.0, &mut reader)?;
let fde_count = match fde_count {
Expand Down Expand Up @@ -228,7 +234,10 @@ impl<'a, R: Reader + 'a> EhHdrTable<'a, R> {
};

match pivot.cmp(&address) {
Ordering::Equal => break,
Ordering::Equal => {
reader = tail;
break;
}
Ordering::Less => {
reader = tail;
len = len - (len / 2);
Expand Down

0 comments on commit caa8bda

Please sign in to comment.