From 71701b5667f73942271dba7ac06f23d66a03b911 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Thu, 3 Oct 2024 22:24:54 -0600 Subject: [PATCH] Update all dependencies --- Cargo.lock | 46 +++++++++++++++++++++------------------------- Cargo.toml | 8 ++++---- src/util/rarc.rs | 28 ++++++++++++++-------------- src/util/u8_arc.rs | 14 ++++++++------ 4 files changed, 47 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f39dc07..240005a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -247,9 +247,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.22" +version = "1.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" +checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" dependencies = [ "jobserver", "libc", @@ -384,15 +384,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2e06f9bce634a3c898eb1e5cb949ff63133cbb218af93cc9b38b31d6f3ea285" -[[package]] -name = "cwextab" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f1036150ed9aa3265b83b9755a14db1600231e0478e678241e4f4d7c30bcf6" -dependencies = [ - "thiserror", -] - [[package]] name = "cwextab" version = "1.0.2" @@ -413,7 +404,7 @@ dependencies = [ "base64", "crossterm", "cwdemangle", - "cwextab 1.0.2", + "cwextab", "dyn-clone", "enable-ansi-support", "filetime", @@ -455,7 +446,7 @@ dependencies = [ "tracing-attributes", "tracing-subscriber", "xxhash-rust", - "zerocopy 0.7.35", + "zerocopy 0.8.0", ] [[package]] @@ -625,6 +616,12 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + [[package]] name = "heck" version = "0.5.0" @@ -669,12 +666,12 @@ checksum = "d9f1a0777d972970f204fdf8ef319f1f4f8459131636d7e3c96c5d59570d0fa6" [[package]] name = "indexmap" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.0", ] [[package]] @@ -782,9 +779,9 @@ dependencies = [ [[package]] name = "liblzma-sys" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63117d31458acdb7b406f6c60090aa8e1e7cd6e283f8ee02ce585ed68c53fe39" +checksum = "6630cb23edeb2e563cd6c30d4117554c69646871455843c33ddcb1d9aef82ecf" dependencies = [ "cc", "libc", @@ -1022,14 +1019,14 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "objdiff-core" -version = "2.1.0" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca74e690bcdff2375aafe70b82a21e9806ff455ccf62b43500a01dadd5470b21" +checksum = "3ec5e2ba3ab275d85ec500ed6dd2c617015d7bf72435b423785457def47217fc" dependencies = [ "anyhow", "byteorder", "cwdemangle", - "cwextab 0.3.1", + "cwextab", "filetime", "flagset", "log", @@ -1053,7 +1050,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "crc32fast", - "hashbrown", + "hashbrown 0.14.5", "indexmap", "memchr", ] @@ -1311,9 +1308,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] @@ -2160,7 +2157,6 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ - "byteorder", "zerocopy-derive 0.7.35", ] diff --git a/Cargo.toml b/Cargo.toml index 5eab5be..4e0cded 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ base16ct = "0.2" base64 = "0.22" crossterm = "0.28" cwdemangle = "1.0" -cwextab = "1.0.2" +cwextab = "1.0" dyn-clone = "1.0" enable-ansi-support = "0.2" filetime = "0.2" @@ -41,7 +41,7 @@ flagset = { version = "0.4", features = ["serde"] } glob = "0.3" hex = "0.4" indent = "0.1" -indexmap = "2.5" +indexmap = "2.6" itertools = "0.13" log = "0.4" memchr = "2.7" @@ -51,7 +51,7 @@ nintendo-lz = "0.1" nodtool = "1.4" #nodtool = { path = "../nod-rs/nodtool" } num_enum = "0.7" -objdiff-core = { version = "2.1", features = ["ppc"] } +objdiff-core = { version = "2.2", features = ["ppc"] } #objdiff-core = { path = "../objdiff/objdiff-core", features = ["ppc"] } object = { version = "0.36", features = ["read_core", "std", "elf", "write_std"], default-features = false } once_cell = "1.20" @@ -75,7 +75,7 @@ tracing = "0.1" tracing-attributes = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } xxhash-rust = { version = "0.8", features = ["xxh3"] } -zerocopy = { version = "0.7", features = ["derive"] } +zerocopy = { version = "0.8", features = ["derive"] } [target.'cfg(target_env = "musl")'.dependencies] mimalloc = "0.1" diff --git a/src/util/rarc.rs b/src/util/rarc.rs index 66d9896..f1fe742 100644 --- a/src/util/rarc.rs +++ b/src/util/rarc.rs @@ -1,12 +1,12 @@ use std::{borrow::Cow, ffi::CStr}; -use zerocopy::{big_endian::*, AsBytes, FromBytes, FromZeroes}; +use zerocopy::{big_endian::*, FromBytes, Immutable, IntoBytes, KnownLayout}; use crate::static_assert; pub const RARC_MAGIC: [u8; 4] = *b"RARC"; -#[derive(Copy, Clone, Debug, PartialEq, FromBytes, FromZeroes, AsBytes)] +#[derive(Copy, Clone, Debug, PartialEq, FromBytes, IntoBytes, Immutable, KnownLayout)] #[repr(C, align(4))] pub struct RarcHeader { /// Magic identifier. (Always "RARC") @@ -40,7 +40,7 @@ impl RarcHeader { pub fn data_len(&self) -> u32 { self.data_len.get() } } -#[derive(Copy, Clone, Debug, PartialEq, FromBytes, FromZeroes, AsBytes)] +#[derive(Copy, Clone, Debug, PartialEq, FromBytes, IntoBytes, Immutable, KnownLayout)] #[repr(C, align(4))] struct RarcInfo { /// Number of directories in the directory table. @@ -63,7 +63,7 @@ struct RarcInfo { static_assert!(size_of::() == 0x20); -#[derive(Copy, Clone, Debug, PartialEq, FromBytes, FromZeroes, AsBytes)] +#[derive(Copy, Clone, Debug, PartialEq, FromBytes, IntoBytes, Immutable, KnownLayout)] #[repr(C, align(4))] pub struct RarcNode { /// Index of the node. (0xFFFF for directories) @@ -104,7 +104,7 @@ impl RarcNode { pub fn data_length(&self) -> u32 { self.data_length.get() } } -#[derive(Copy, Clone, Debug, PartialEq, FromBytes, FromZeroes, AsBytes)] +#[derive(Copy, Clone, Debug, PartialEq, FromBytes, IntoBytes, Immutable, KnownLayout)] #[repr(C, align(4))] pub struct RarcDirectory { /// Identifier of the directory. @@ -149,7 +149,7 @@ pub struct RarcView<'a> { impl<'a> RarcView<'a> { /// Create a new RARC view from a buffer. pub fn new(buf: &'a [u8]) -> Result { - let Some(header) = RarcHeader::ref_from_prefix(buf) else { + let Ok((header, remaining)) = RarcHeader::ref_from_prefix(buf) else { return Err("Buffer not large enough for RARC header"); }; if header.magic != RARC_MAGIC { @@ -161,32 +161,32 @@ impl<'a> RarcView<'a> { // All offsets are relative to the _end_ of the header, so we can // just trim the header from the buffer and use the offsets as is. - let buf = &buf[size_of::()..]; - let Some(info) = RarcInfo::ref_from_prefix(buf) else { + let Ok((info, _)) = RarcInfo::ref_from_prefix(remaining) else { return Err("Buffer not large enough for RARC info"); }; let directory_table_offset = info.directory_offset.get() as usize; let directory_table_size = info.directory_count.get() as usize * size_of::(); - let directories_buf = buf + let directories_buf = remaining .get(directory_table_offset..directory_table_offset + directory_table_size) .ok_or("RARC directory table out of bounds")?; - let directories = - RarcDirectory::slice_from(directories_buf).ok_or("RARC directory table not aligned")?; + let directories = <[RarcDirectory]>::ref_from_bytes(directories_buf) + .map_err(|_| "RARC directory table not aligned")?; if directories.is_empty() || directories[0].identifier != *b"ROOT" { return Err("RARC root directory not found"); } let node_table_offset = info.node_offset.get() as usize; let node_table_size = info.node_count.get() as usize * size_of::(); - let nodes_buf = buf + let nodes_buf = remaining .get(node_table_offset..node_table_offset + node_table_size) .ok_or("RARC node table out of bounds")?; - let nodes = RarcNode::slice_from(nodes_buf).ok_or("RARC node table not aligned")?; + let nodes = + <[RarcNode]>::ref_from_bytes(nodes_buf).map_err(|_| "RARC node table not aligned")?; let string_table_offset = info.string_table_offset.get() as usize; let string_table_size = info.string_table_len.get() as usize; - let string_table = buf + let string_table = remaining .get(string_table_offset..string_table_offset + string_table_size) .ok_or("RARC string table out of bounds")?; diff --git a/src/util/u8_arc.rs b/src/util/u8_arc.rs index 8478703..f776897 100644 --- a/src/util/u8_arc.rs +++ b/src/util/u8_arc.rs @@ -1,14 +1,14 @@ use std::{borrow::Cow, ffi::CStr, mem::size_of}; use anyhow::Result; -use zerocopy::{big_endian::U32, AsBytes, FromBytes, FromZeroes}; +use zerocopy::{big_endian::U32, FromBytes, Immutable, IntoBytes, KnownLayout}; use crate::static_assert; pub const U8_MAGIC: [u8; 4] = [0x55, 0xAA, 0x38, 0x2D]; /// U8 archive header. -#[derive(Clone, Debug, PartialEq, FromBytes, FromZeroes, AsBytes)] +#[derive(Clone, Debug, PartialEq, FromBytes, IntoBytes, Immutable, KnownLayout)] #[repr(C, align(4))] pub struct U8Header { magic: [u8; 4], @@ -32,7 +32,7 @@ pub enum U8NodeKind { } /// An individual file system node. -#[derive(Copy, Clone, Debug, PartialEq, FromBytes, FromZeroes, AsBytes)] +#[derive(Copy, Clone, Debug, PartialEq, FromBytes, IntoBytes, Immutable, KnownLayout)] #[repr(C, align(4))] pub struct U8Node { kind: u8, @@ -91,7 +91,7 @@ pub struct U8View<'a> { impl<'a> U8View<'a> { /// Create a new U8 view from a buffer. pub fn new(buf: &'a [u8]) -> Result { - let Some(header) = U8Header::ref_from_prefix(buf) else { + let Ok((header, _)) = U8Header::ref_from_prefix(buf) else { return Err("Buffer not large enough for U8 header"); }; if header.magic != U8_MAGIC { @@ -101,7 +101,8 @@ impl<'a> U8View<'a> { let nodes_buf = buf .get(node_table_offset..node_table_offset + header.node_table_size.get() as usize) .ok_or("U8 node table out of bounds")?; - let root_node = U8Node::ref_from_prefix(nodes_buf).ok_or("U8 root node not aligned")?; + let (root_node, _) = + U8Node::ref_from_prefix(nodes_buf).map_err(|_| "U8 root node not aligned")?; if root_node.kind() != U8NodeKind::Directory { return Err("U8 root node is not a directory"); } @@ -113,7 +114,8 @@ impl<'a> U8View<'a> { return Err("U8 node table size mismatch"); } let (nodes_buf, string_table) = nodes_buf.split_at(node_count * size_of::()); - let nodes = U8Node::slice_from(nodes_buf).ok_or("U8 node table not aligned")?; + let nodes = + <[U8Node]>::ref_from_bytes(nodes_buf).map_err(|_| "U8 node table not aligned")?; Ok(Self { header, nodes, string_table }) }