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

fix: Ensure we can parse Unreal4 crashes with 0-length files (ISSUE-1459, ISSUE-1454) #565

Merged
merged 2 commits into from
May 9, 2022
Merged
Changes from 1 commit
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
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