mirror of
https://github.com/storytold/craft-anything.git
synced 2026-11-20 06:21:00 +01:00
Network captures, ZIP, Unity, Unreal, Python, pixel, tensor, Mach-O, code signature, PE, Go, .NET, ELF and DOS readers keep to their declared lengths and refuse impossible values. Trailing padding in a ZIP entry's extra field is no longer an error. Closes #974. Co-authored-by: Afloat <ShuffleMonkey@163.com> Co-authored-by: NetterSilver <133535268+Silvertree2010@users.noreply.github.com>
20 lines
812 B
Rust
20 lines
812 B
Rust
use craft_anything_formats::{FormatError, unreal_iostore};
|
|
|
|
#[test]
|
|
fn all_reserved_header_bytes_must_be_present() {
|
|
let fixture = craft_anything_testkit::games::unreal_utoc(9, u32::MAX);
|
|
for len in 0..unreal_iostore::HEADER_SIZE {
|
|
assert!(matches!(unreal_iostore::header(&fixture[..len]), Err(FormatError::Truncated(_))), "a {len}-byte header is incomplete");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn complete_headers_read_for_each_supported_version() {
|
|
let mut fixture = craft_anything_testkit::games::unreal_utoc(9, u32::MAX);
|
|
for version in 1..=unreal_iostore::MAX_VERSION {
|
|
fixture[16] = version;
|
|
let h = unreal_iostore::header(&fixture[..unreal_iostore::HEADER_SIZE]).unwrap();
|
|
assert_eq!((h.version, h.chunk_count, h.block_count, h.block_size), (version, 3, 4, 65536));
|
|
}
|
|
}
|