From fed52b2bf452e22c49bb2481b52c9e6ee8e5c399 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 24 Oct 2025 13:35:30 -0700 Subject: [PATCH 1/4] Fix elided namespace warnings in Rust 1.90. (#397) * Fix elided namespace warnings in Rust 1.90. CI builds with warnings-as-errors, so this is needed to fix CI. * Update CI from windows-2019 to windows-2022. --- .github/workflows/main.yml | 6 +++--- cap-async-std/src/net/tcp_listener.rs | 2 +- cap-async-std/src/os/unix/net/unix_listener.rs | 2 +- cap-primitives/src/fs/via_parent/open_parent.rs | 2 +- cap-std/src/net/tcp_listener.rs | 2 +- cap-std/src/os/unix/net/unix_listener.rs | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 243d15ce7..43cbfc790 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -201,7 +201,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - build: [stable, windows-latest, windows-2019, macos-latest, macos-13, beta, ubuntu-22.04, aarch64-ubuntu] + build: [stable, windows-latest, windows-2022, macos-latest, macos-13, beta, ubuntu-22.04, aarch64-ubuntu] include: - build: stable os: ubuntu-latest @@ -209,8 +209,8 @@ jobs: - build: windows-latest os: windows-latest rust: stable - - build: windows-2019 - os: windows-2019 + - build: windows-2022 + os: windows-2022 rust: stable - build: macos-latest os: macos-latest diff --git a/cap-async-std/src/net/tcp_listener.rs b/cap-async-std/src/net/tcp_listener.rs index b14ad3370..b097ad681 100644 --- a/cap-async-std/src/net/tcp_listener.rs +++ b/cap-async-std/src/net/tcp_listener.rs @@ -67,7 +67,7 @@ impl TcpListener { /// /// This corresponds to [`async_std::net::TcpListener::incoming`]. #[inline] - pub fn incoming(&self) -> Incoming { + pub fn incoming(&self) -> Incoming<'_> { let incoming = self.std.incoming(); Incoming::from_std(incoming) } diff --git a/cap-async-std/src/os/unix/net/unix_listener.rs b/cap-async-std/src/os/unix/net/unix_listener.rs index 919167102..bc00e0b6d 100644 --- a/cap-async-std/src/os/unix/net/unix_listener.rs +++ b/cap-async-std/src/os/unix/net/unix_listener.rs @@ -69,7 +69,7 @@ impl UnixListener { /// /// [`async_std::os::unix::net::UnixListener::incoming`]: https://docs.rs/async-std/latest/async_std/os/unix/net/struct.UnixListener.html#method.incoming #[inline] - pub fn incoming(&self) -> Incoming { + pub fn incoming(&self) -> Incoming<'_> { let incoming = self.std.incoming(); Incoming::from_std(incoming) } diff --git a/cap-primitives/src/fs/via_parent/open_parent.rs b/cap-primitives/src/fs/via_parent/open_parent.rs index 3b6fd2c54..fe52e6c7d 100644 --- a/cap-primitives/src/fs/via_parent/open_parent.rs +++ b/cap-primitives/src/fs/via_parent/open_parent.rs @@ -37,7 +37,7 @@ pub(super) fn open_parent<'path, 'borrow>( /// - Append a `.` to a path with a trailing `..` to avoid requiring our /// callers to special-case `..`. /// - Bare absolute paths are ok. -fn split_parent(path: &Path) -> Option<(&Path, Component)> { +fn split_parent(path: &Path) -> Option<(&Path, Component<'_>)> { if path.as_os_str().is_empty() { return None; } diff --git a/cap-std/src/net/tcp_listener.rs b/cap-std/src/net/tcp_listener.rs index 2f4f1b042..5d6c95b03 100644 --- a/cap-std/src/net/tcp_listener.rs +++ b/cap-std/src/net/tcp_listener.rs @@ -72,7 +72,7 @@ impl TcpListener { /// /// This corresponds to [`std::net::TcpListener::incoming`]. #[inline] - pub fn incoming(&self) -> Incoming { + pub fn incoming(&self) -> Incoming<'_> { let incoming = self.std.incoming(); Incoming::from_std(incoming) } diff --git a/cap-std/src/os/unix/net/unix_listener.rs b/cap-std/src/os/unix/net/unix_listener.rs index 8ecf9aaa8..5f5d65de0 100644 --- a/cap-std/src/os/unix/net/unix_listener.rs +++ b/cap-std/src/os/unix/net/unix_listener.rs @@ -90,7 +90,7 @@ impl UnixListener { /// /// [`std::os::unix::net::UnixListener::incoming`]: https://doc.rust-lang.org/std/os/unix/net/struct.UnixListener.html#method.incoming #[inline] - pub fn incoming(&self) -> Incoming { + pub fn incoming(&self) -> Incoming<'_> { let incoming = self.std.incoming(); Incoming::from_std(incoming) } From c9e11457295f69acea7a225247abc0b74006543a Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 24 Oct 2025 14:11:27 -0700 Subject: [PATCH 2/4] Pin some dependencies for MSRV compatibilty. (#398) --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 43cbfc790..b9603350f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -373,7 +373,10 @@ jobs: toolchain: ${{ matrix.rust }} - name: Use specific dependency versions for Rust 1.63 compatibility. - run: cargo update --package=once_cell --precise=1.20.3 + run: | + cargo update --package=once_cell --precise=1.20.3 + cargo update --package=async-io --precise=2.5.0 + cargo update --package=polling --precise=3.10.0 # Don't use --all-features because some of the features have dependencies # that don't work on newer Rust versions. From 4e8ba003ad00920f21edcb2d126cc15ed302508d Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 24 Oct 2025 14:11:53 -0700 Subject: [PATCH 3/4] Fix `Dir::symlink_metadata` of "/" on Linux. (#396) Fix an overzealous optimization on Linux which inappropriately allowed `Dir::symlink_metadata` on a path of "/" to succeed. Fixes bytecodealliance/wasmtime#11606. --- .../src/rustix/linux/fs/stat_impl.rs | 11 +++++----- tests/fs_additional.rs | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/cap-primitives/src/rustix/linux/fs/stat_impl.rs b/cap-primitives/src/rustix/linux/fs/stat_impl.rs index b018c16da..df358a019 100644 --- a/cap-primitives/src/rustix/linux/fs/stat_impl.rs +++ b/cap-primitives/src/rustix/linux/fs/stat_impl.rs @@ -18,13 +18,14 @@ pub(crate) fn stat_impl( use crate::fs::{stat_unchecked, OpenOptionsExt}; use std::path::Component; - // Optimization: if path has exactly one component and it's not ".." and - // we're not following symlinks we can go straight to `stat_unchecked`, - // which is faster than doing an open with a separate fstat. + // Optimization: if path has exactly one component and it's not ".." or + // anything non-normal and we're not following symlinks we can go straight + // to `stat_unchecked`, which is faster than doing an open with a separate + // `fstat`. if follow == FollowSymlinks::No { let mut components = path.components(); - if let Some(component) = components.next() { - if components.next().is_none() && component != Component::ParentDir { + if let Some(Component::Normal(component)) = components.next() { + if components.next().is_none() { return stat_unchecked(start, component.as_ref(), FollowSymlinks::No); } } diff --git a/tests/fs_additional.rs b/tests/fs_additional.rs index 4fe7a17c4..647168192 100644 --- a/tests/fs_additional.rs +++ b/tests/fs_additional.rs @@ -1380,3 +1380,23 @@ fn dotdot_slashdot_at_end_of_symlink_all_inside_dir() { let _entry = check!(entry); } } + +/// Ensure that a path of "/" is rejected. +#[test] +fn statat_slash() { + let tmpdir = tmpdir(); + + error_contains!(tmpdir.metadata("/"), "a path led outside of the filesystem"); + error_contains!( + tmpdir.metadata("/foo"), + "a path led outside of the filesystem" + ); + error_contains!( + tmpdir.symlink_metadata("/"), + "a path led outside of the filesyste" + ); + error_contains!( + tmpdir.symlink_metadata("/foo"), + "a path led outside of the filesyste" + ); +} From e8cbd4b80788bc851c10c792c3f42c22fb89fb92 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 24 Oct 2025 14:14:20 -0700 Subject: [PATCH 4/4] chore: Release --- Cargo.toml | 16 ++++++++-------- cap-async-std/Cargo.toml | 4 ++-- cap-directories/Cargo.toml | 4 ++-- cap-fs-ext/Cargo.toml | 8 ++++---- cap-net-ext/Cargo.toml | 6 +++--- cap-primitives/Cargo.toml | 2 +- cap-rand/Cargo.toml | 2 +- cap-std/Cargo.toml | 4 ++-- cap-tempfile/Cargo.toml | 4 ++-- cap-time-ext/Cargo.toml | 6 +++--- 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f63baf538..650d8e9e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cap-std-workspace" -version = "3.4.4" +version = "3.4.5" description = "Capability-based version of the Rust standard library" authors = [ "Dan Gohman ", @@ -19,13 +19,13 @@ rust-version = "1.63" [dev-dependencies] async-std = { version = "1.13.0", features = ["attributes", "io_safety"] } anyhow = "1.0.37" -cap-async-std = { path = "cap-async-std", version = "3.4.4" } -cap-fs-ext = { path = "cap-fs-ext", version = "3.4.4" } -cap-net-ext = { path = "cap-net-ext", version = "3.4.4" } -cap-directories = { path = "cap-directories", version = "3.4.4" } -cap-std = { path = "cap-std", version = "3.4.4" } -cap-tempfile = { path = "cap-tempfile", version = "3.4.4" } -cap-rand = { path = "cap-rand", version = "3.4.4" } +cap-async-std = { path = "cap-async-std", version = "3.4.5" } +cap-fs-ext = { path = "cap-fs-ext", version = "3.4.5" } +cap-net-ext = { path = "cap-net-ext", version = "3.4.5" } +cap-directories = { path = "cap-directories", version = "3.4.5" } +cap-std = { path = "cap-std", version = "3.4.5" } +cap-tempfile = { path = "cap-tempfile", version = "3.4.5" } +cap-rand = { path = "cap-rand", version = "3.4.5" } rand = "0.8.1" tempfile = "3.1.0" camino = "1.0.5" diff --git a/cap-async-std/Cargo.toml b/cap-async-std/Cargo.toml index 2d0fd2ee4..c202e6496 100644 --- a/cap-async-std/Cargo.toml +++ b/cap-async-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cap-async-std" -version = "3.4.4" +version = "3.4.5" description = "Capability-based version of async-std" authors = [ "Dan Gohman ", @@ -15,7 +15,7 @@ edition = "2021" [dependencies] arf-strings = { version = "0.7.0", optional = true } async-std = { version = "1.13.0", features = ["attributes", "io_safety"] } -cap-primitives = { path = "../cap-primitives", version = "^3.4.4" } +cap-primitives = { path = "../cap-primitives", version = "^3.4.5" } io-lifetimes = { version = "2.0.0", default-features = false, features = ["async-std"] } io-extras = { version = "0.18.3", features = ["use_async_std"] } camino = { version = "1.0.5", optional = true } diff --git a/cap-directories/Cargo.toml b/cap-directories/Cargo.toml index c8e81db26..6a060fde0 100644 --- a/cap-directories/Cargo.toml +++ b/cap-directories/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cap-directories" -version = "3.4.4" +version = "3.4.5" description = "Capability-based standard directories for config, cache and other data" authors = [ "Dan Gohman ", @@ -13,7 +13,7 @@ repository = "https://github.com/bytecodealliance/cap-std" edition = "2021" [dependencies] -cap-std = { path = "../cap-std", version = "^3.4.4" } +cap-std = { path = "../cap-std", version = "^3.4.5" } directories-next = "2.0.0" [target.'cfg(not(windows))'.dependencies] diff --git a/cap-fs-ext/Cargo.toml b/cap-fs-ext/Cargo.toml index 8d657362e..c5b9df260 100644 --- a/cap-fs-ext/Cargo.toml +++ b/cap-fs-ext/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cap-fs-ext" -version = "3.4.4" +version = "3.4.5" description = "Extension traits for `Dir`, `File`, etc." authors = [ "Dan Gohman ", @@ -14,9 +14,9 @@ edition = "2021" [dependencies] arf-strings = { version = "0.7.0", optional = true } -cap-async-std = { path = "../cap-async-std", optional = true, version = "3.4.4" } -cap-std = { path = "../cap-std", optional = true, version = "3.4.4" } -cap-primitives = { path = "../cap-primitives", version = "3.4.4" } +cap-async-std = { path = "../cap-async-std", optional = true, version = "3.4.5" } +cap-std = { path = "../cap-std", optional = true, version = "3.4.5" } +cap-primitives = { path = "../cap-primitives", version = "3.4.5" } io-lifetimes = { version = "2.0.0", default-features = false } async-std = { version = "1.13.0", features = ["io_safety", "attributes"], optional = true } async-trait = { version = "0.1.42", optional = true } diff --git a/cap-net-ext/Cargo.toml b/cap-net-ext/Cargo.toml index f44c47982..6cdcada25 100644 --- a/cap-net-ext/Cargo.toml +++ b/cap-net-ext/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cap-net-ext" -version = "3.4.4" +version = "3.4.5" description = "Extension traits for `TcpListener`, `Pool`, etc." authors = [ "Dan Gohman ", @@ -13,7 +13,7 @@ repository = "https://github.com/bytecodealliance/cap-std" edition = "2021" [dependencies] -cap-std = { path = "../cap-std", version = "^3.4.4" } -cap-primitives = { path = "../cap-primitives", version = "^3.4.4" } +cap-std = { path = "../cap-std", version = "^3.4.5" } +cap-primitives = { path = "../cap-primitives", version = "^3.4.5" } rustix = { version = "1.0.0", features = ["net"] } smallvec = "1.10" diff --git a/cap-primitives/Cargo.toml b/cap-primitives/Cargo.toml index a984efef0..b93d29fd7 100644 --- a/cap-primitives/Cargo.toml +++ b/cap-primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cap-primitives" -version = "3.4.4" +version = "3.4.5" description = "Capability-based primitives" authors = [ "Dan Gohman ", diff --git a/cap-rand/Cargo.toml b/cap-rand/Cargo.toml index 6de4c5977..25750a283 100644 --- a/cap-rand/Cargo.toml +++ b/cap-rand/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cap-rand" -version = "3.4.4" +version = "3.4.5" description = "Capability-based random number generators" authors = [ "Dan Gohman ", diff --git a/cap-std/Cargo.toml b/cap-std/Cargo.toml index 399c46aaf..9487ba2fa 100644 --- a/cap-std/Cargo.toml +++ b/cap-std/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cap-std" -version = "3.4.4" +version = "3.4.5" description = "Capability-based version of the Rust standard library" authors = [ "Dan Gohman ", @@ -18,7 +18,7 @@ rustdoc-args = ["--cfg=docsrs"] [dependencies] arf-strings = { version = "0.7.0", optional = true } -cap-primitives = { path = "../cap-primitives", version = "^3.4.4" } +cap-primitives = { path = "../cap-primitives", version = "^3.4.5" } io-extras = "0.18.3" io-lifetimes = { version = "2.0.0", default-features = false } camino = { version = "1.0.5", optional = true } diff --git a/cap-tempfile/Cargo.toml b/cap-tempfile/Cargo.toml index 692c3f2eb..cc4b294e6 100644 --- a/cap-tempfile/Cargo.toml +++ b/cap-tempfile/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cap-tempfile" -version = "3.4.4" +version = "3.4.5" description = "Capability-based temporary directories" authors = [ "Dan Gohman ", @@ -13,7 +13,7 @@ repository = "https://github.com/bytecodealliance/cap-std" edition = "2021" [dependencies] -cap-std = { path = "../cap-std", version = "^3.4.4" } +cap-std = { path = "../cap-std", version = "^3.4.5" } uuid = { version = "1.0.0", features = ["v4"] } camino = { version = "1.0.5", optional = true } diff --git a/cap-time-ext/Cargo.toml b/cap-time-ext/Cargo.toml index 21974598d..952a49f48 100644 --- a/cap-time-ext/Cargo.toml +++ b/cap-time-ext/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cap-time-ext" -version = "3.4.4" +version = "3.4.5" description = "Extension traits for `SystemClock` and `MonotonicClock`" authors = [ "Dan Gohman ", @@ -14,8 +14,8 @@ edition = "2021" [dependencies] ambient-authority = "0.0.2" -cap-primitives = { path = "../cap-primitives", version = "^3.4.4" } -cap-std = { path = "../cap-std", optional = true, version = "^3.4.4" } +cap-primitives = { path = "../cap-primitives", version = "^3.4.5" } +cap-std = { path = "../cap-std", optional = true, version = "^3.4.5" } iana-time-zone = "0.1.57" [target.'cfg(not(windows))'.dependencies]