Skip to content

Commit

Permalink
fix: Ensure we can parse Unreal crashes with 0-length files (ISSUE-1459
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem authored May 9, 2022
1 parent 886f13e commit 9fd0344
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

**Fixes**:

- Make sure to correctly parse Unreal crash reports with zero-length files ([#565](https://github.com/getsentry/symbolic/pull/565))

## 8.7.1

**Fixes**:
Expand Down
6 changes: 4 additions & 2 deletions symbolic-unreal/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl TryFromCtx<'_, Endian> for AnsiString {
let len = data.gread_with::<u32>(&mut offset, context)?;
let bytes = data.gread_with::<&[u8]>(&mut offset, len as usize)?;

// Convert into UTF-8 and trucate the trailing zeros
// Convert into UTF-8 and truncate the trailing zeros
let mut string = String::from_utf8_lossy(bytes).into_owned();
let actual_len = string.trim_end_matches('\0').len();
string.truncate(actual_len);
Expand Down Expand Up @@ -102,7 +102,9 @@ impl TryFromCtx<'_, usize> for Unreal4FileMeta {
};

// Ensure that the buffer contains enough data
data.gread_with::<&[u8]>(&mut offset, len)?;
if len > 0 {
data.gread_with::<&[u8]>(&mut offset, len)?;
}

Ok((file_meta, offset))
}
Expand Down

0 comments on commit 9fd0344

Please sign in to comment.