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
2 changes: 1 addition & 1 deletion lib/src/crashlog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl CrashLog {
};
queue.push_front(region)
}
Err(err) => log::error!("Invalid region in Box record: {err}"),
Err(err) => log::warn!("Invalid region in Box record: {err}"),
}
}

Expand Down
2 changes: 2 additions & 0 deletions lib/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub enum Error {
MissingDecodeDefinitions(Version),
InvalidBootErrorRecordRegion,
InvalidHeader,
EmptyRegion,
InvalidHeaderType(u16),
InvalidRecordType(u8),
InvalidProductID(u32),
Expand Down Expand Up @@ -57,6 +58,7 @@ impl fmt::Display for Error {
}
Error::InvalidBootErrorRecordRegion => write!(f, "Invalid Boot Error Record region"),
Error::InvalidHeader => write!(f, "Invalid Crash Log Header"),
Error::EmptyRegion => write!(f, "The Crash Log Region is not populated"),
Error::InvalidHeaderType(ht) => write!(f, "Invalid Crash Log Header Type: {ht}"),
Error::InvalidRecordType(rt) => write!(f, "Unknown Crash Log Record Type: {rt:#x}"),
Error::InvalidProductID(pid) => write!(f, "Unknown Crash Log Product ID: {pid:#x}"),
Expand Down
4 changes: 4 additions & 0 deletions lib/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ impl Region {
cursor += record_size;
}

if region.records.is_empty() {
return Err(Error::EmptyRegion);
}

Ok(region)
}

Expand Down
6 changes: 6 additions & 0 deletions lib/tests/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ fn from_slice() {

assert!(region.is_ok());
}

#[test]
fn empty() {
let region = Region::from_slice(&[]);
assert!(region.is_err());
}