Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow invalid ranges in RngListIter #715

Merged
merged 3 commits into from
May 24, 2024
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
11 changes: 3 additions & 8 deletions src/read/loclists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,15 +650,10 @@ impl<R: Reader> LocListIter<R> {
}
};

if range.begin == tombstone {
if range.begin == tombstone || range.begin > range.end {
return Ok(None);
}

if range.begin > range.end {
self.raw.input.empty();
return Err(Error::InvalidLocationAddressRange);
}

Ok(Some(LocationListEntry { range, data }))
}
}
Expand Down Expand Up @@ -1522,7 +1517,7 @@ mod tests {
debug_addr_base,
)
.unwrap();
assert_eq!(locations.next(), Err(Error::InvalidLocationAddressRange));
assert_eq!(locations.next(), Ok(None));

// An invalid location range after wrapping.
let mut locations = loclists
Expand All @@ -1534,7 +1529,7 @@ mod tests {
debug_addr_base,
)
.unwrap();
assert_eq!(locations.next(), Err(Error::InvalidLocationAddressRange));
assert_eq!(locations.next(), Ok(None));

// An invalid offset.
match loclists.locations(
Expand Down
5 changes: 0 additions & 5 deletions src/read/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,6 @@ pub enum Error {
UnknownCallFrameInstruction(constants::DwCfa),
/// The end of an address range was before the beginning.
InvalidAddressRange,
/// The end offset of a loc list entry was before the beginning.
InvalidLocationAddressRange,
/// Encountered a call frame instruction in a context in which it is not
/// valid.
CfiInstructionInInvalidContext,
Expand Down Expand Up @@ -537,9 +535,6 @@ impl Error {
Error::InvalidAddressRange => {
"The end of an address range must not be before the beginning."
}
Error::InvalidLocationAddressRange => {
"The end offset of a location list entry must not be before the beginning."
}
Error::CfiInstructionInInvalidContext => {
"Encountered a call frame instruction in a context in which it is not valid."
}
Expand Down
11 changes: 3 additions & 8 deletions src/read/rnglists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,15 +569,10 @@ impl<R: Reader> RngListIter<R> {
}
};

if range.begin == tombstone {
if range.begin == tombstone || range.begin > range.end {
return Ok(None);
}

if range.begin > range.end {
self.raw.input.empty();
return Err(Error::InvalidAddressRange);
}

Ok(Some(range))
}
}
Expand Down Expand Up @@ -1402,7 +1397,7 @@ mod tests {
debug_addr_base,
)
.unwrap();
assert_eq!(ranges.next(), Err(Error::InvalidAddressRange));
assert_eq!(ranges.next(), Ok(None));

// An invalid range after wrapping.
let mut ranges = rnglists
Expand All @@ -1414,7 +1409,7 @@ mod tests {
debug_addr_base,
)
.unwrap();
assert_eq!(ranges.next(), Err(Error::InvalidAddressRange));
assert_eq!(ranges.next(), Ok(None));

// An invalid offset.
match rnglists.ranges(
Expand Down
Loading