mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-23 07:50:45 +01:00
zip 9: entry names are fallible; pin 9.0.5
zip 9 decodes entry names on demand, so ZipArchive::file_names and ZipFile::name return a Result. Package lookups (FBX, usdz) skip names that do not decode, and a project entry with a bad name is a malformed project. The usdz test reads data_start as an Option. The lockfile pins 9.0.5 rather than the two-day-old 9.2.0.
This commit is contained in:
1 parent
ecec51d616
commit
8ffc94e286
5 files changed
+20
-24
No files matched your search
Generated
+13
-17
@@ -563,7 +563,7 @@ dependencies = [
|
||||
"maybe-owned",
|
||||
"rustix 1.1.5",
|
||||
"rustix-linux-procfs",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
"winx",
|
||||
]
|
||||
|
||||
@@ -1171,7 +1171,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1476,10 +1476,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"r-efi 6.0.0",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2814,7 +2812,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3416,7 +3414,7 @@ dependencies = [
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.12.1",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3715,7 +3713,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -3797,10 +3795,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"getrandom 0.4.3",
|
||||
"getrandom 0.3.4",
|
||||
"once_cell",
|
||||
"rustix 1.1.5",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4247,9 +4245,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "typed-path"
|
||||
version = "0.13.0"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ce898823d8cd0f028662d2f349694b1af0a5cc9be83f1d213a00d3147445e1e"
|
||||
checksum = "54ec2755506471f54baf5e4bb5499d8e510cc1caf271270e778a736bd2d7336c"
|
||||
|
||||
[[package]]
|
||||
name = "typeid"
|
||||
@@ -4265,7 +4263,7 @@ checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"
|
||||
dependencies = [
|
||||
"memoffset",
|
||||
"tempfile",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4784,7 +4782,7 @@ version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5487,18 +5485,16 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zip"
|
||||
version = "9.2.0"
|
||||
version = "9.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f5b58784007ff6e5f280ec82c8596686a3b9b5dd5836c63288d4479f84728b9"
|
||||
checksum = "6e04976da629d3b04204ba8105b396a193af8ad2583b2c79bfb3ab8af580a11e"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"flate2",
|
||||
"getrandom 0.4.3",
|
||||
"indexmap",
|
||||
"memchr",
|
||||
"nix",
|
||||
"typed-path",
|
||||
"windows-sys 0.61.2",
|
||||
"zopfli",
|
||||
]
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ pub(crate) fn read(bytes: &[u8]) -> Result<RawMesh> {
|
||||
if zip.len() > MAX_ZIP_ENTRIES {
|
||||
return Err(FormatError::TooLarge(format!("the FBX package has more than {MAX_ZIP_ENTRIES} entries")));
|
||||
}
|
||||
let name = zip.file_names().filter(|n| super::extension(n) == "fbx").min_by_key(|n| zip.index_for_name(n)).map(str::to_string);
|
||||
let name = zip.file_names().flatten().filter(|n| super::extension(n) == "fbx").min_by_key(|n| zip.index_for_name(n)).map(Cow::into_owned);
|
||||
let name = name.ok_or_else(|| malformed(KIND, "the package contains no FBX file"))?;
|
||||
let fbx = zip_entry(&mut zip, &name, MAX_MESH_FILE_BYTES)
|
||||
.ok_or_else(|| FormatError::TooLarge("the packaged FBX is unreadable or larger than 2 GiB".into()))?;
|
||||
|
||||
@@ -228,8 +228,8 @@ fn read_usdz(bytes: &[u8]) -> Result<(Layer, Package<'_>)> {
|
||||
if zip.len() > MAX_ZIP_ENTRIES {
|
||||
return Err(FormatError::TooLarge(format!("the usdz package has more than {MAX_ZIP_ENTRIES} entries")));
|
||||
}
|
||||
let name = zip.file_names().filter(|n| matches!(super::extension(n).as_str(), "usda" | "usdc" | "usd")).min_by_key(|n| zip.index_for_name(n));
|
||||
let name = name.ok_or_else(|| malformed(KIND, "the usdz package contains no USD layer"))?.to_string();
|
||||
let name = zip.file_names().flatten().filter(|n| matches!(super::extension(n).as_str(), "usda" | "usdc" | "usd")).min_by_key(|n| zip.index_for_name(n));
|
||||
let name = name.ok_or_else(|| malformed(KIND, "the usdz package contains no USD layer"))?.into_owned();
|
||||
let dir = name.rsplit_once('/').map_or("", |(d, _)| d).to_string();
|
||||
let mut package = Package { zip, dir };
|
||||
let data = package.read(&name, MAX_MESH_FILE_BYTES).ok_or_else(|| FormatError::TooLarge("the usdz layer is unreadable or larger than 2 GiB".into()))?;
|
||||
|
||||
@@ -347,16 +347,16 @@ fn usda_usdc_and_usdz_round_trip_with_textures() {
|
||||
round_trip(&m, UsdFormat::Usdc, "usdc", &textures);
|
||||
let usdz = round_trip(&m, UsdFormat::Usdz, "usdz", &textures);
|
||||
let mut zip = zip::ZipArchive::new(std::io::Cursor::new(&usdz)).unwrap();
|
||||
let names: Vec<String> = zip.file_names().map(str::to_string).collect();
|
||||
let names: Vec<String> = zip.file_names().map(|n| n.unwrap().into_owned()).collect();
|
||||
assert_eq!(names.first().map(String::as_str), Some("Test_scene.usdc"));
|
||||
assert_eq!(names.len(), 1 + 7, "the layer and every non-black texture");
|
||||
for i in 0..zip.len() {
|
||||
let mut f = zip.by_index(i).unwrap();
|
||||
assert_eq!(f.compression(), zip::CompressionMethod::Stored);
|
||||
assert_eq!(f.data_start() % 64, 0, "usdz entries are 64-byte aligned");
|
||||
assert_eq!(f.data_start().unwrap() % 64, 0, "usdz entries are 64-byte aligned");
|
||||
let mut data = Vec::new();
|
||||
f.read_to_end(&mut data).unwrap();
|
||||
if f.name().ends_with(".png") {
|
||||
if f.name().unwrap().ends_with(".png") {
|
||||
assert!(image::load_from_memory(&data).is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ fn load<R: Read + Seek>(reader: R) -> Result<ProjectFile> {
|
||||
};
|
||||
for i in 0..zip.len() {
|
||||
let mut f = zip.by_index(i).map_err(zip_err)?;
|
||||
let name = f.name().to_string();
|
||||
let name = f.name().map_err(zip_err)?.into_owned();
|
||||
let size_of = |id: LayerId| texture_set_of(&pf.project, id).and_then(|ts| pf.project.texture_sets.get(ts)).map(|t| t.size());
|
||||
if name == "thumbnail.png" {
|
||||
pf.thumbnail = Some(read_all(&mut f, MAX_THUMBNAIL, &mut budget, &name)?);
|
||||
|
||||
Reference in new issue
Block a user