From 38c792cb781148b7cd04259f48dcbc8d5e8a4e94 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 15 Oct 2026 16:41:34 -0700 Subject: [PATCH 1/9] Fix accidentally duplicated tests. --- tests/fs_additional.rs | 96 ------------------------------------------ 1 file changed, 96 deletions(-) diff --git a/tests/fs_additional.rs b/tests/fs_additional.rs index 7a6c3397..967a3cab 100644 --- a/tests/fs_additional.rs +++ b/tests/fs_additional.rs @@ -1509,99 +1509,3 @@ fn trailing_slash_symlink_more() { ); } } - -/// Test interactions between symlinks and trailing slashes. -#[test] -fn trailing_slash_symlink() { - let tmpdir = tmpdir(); - - check!(tmpdir.create_dir("sandbox")); - check!(symlink_dir("../outside", &tmpdir, "sandbox/hidden")); - check!(symlink_dir("hidden/", &tmpdir, "sandbox/indirect")); - - let sandbox = check!(tmpdir.open_dir("sandbox")); - - for path in ["hidden", "hidden/", "indirect", "indirect/"] { - error!( - sandbox.open_dir(path), - "a path led outside of the filesystem" - ); - error!( - sandbox.read_dir(path), - "a path led outside of the filesystem" - ); - error!( - sandbox.canonicalize(path), - "a path led outside of the filesystem" - ); - } -} - -/// Similar to `trailing_slash_symlink`, but populates the test directory -/// outside the sandbox, so it can cover more cases. -#[test] -fn trailing_slash_symlink_more() { - let tmpdir = tempfile::tempdir().unwrap(); - - check!(std::fs::create_dir(tmpdir.path().join("sandbox"))); - #[cfg(unix)] - { - check!(std::os::unix::fs::symlink( - "../outside", - tmpdir.path().join("sandbox/hidden") - )); - check!(std::os::unix::fs::symlink( - "hidden/", - tmpdir.path().join("sandbox/indirect") - )); - check!(std::os::unix::fs::symlink( - "/.", - tmpdir.path().join("sandbox/root_link") - )); - } - #[cfg(windows)] - { - check!(std::os::windows::fs::symlink_dir( - "../outside", - tmpdir.path().join("sandbox/hidden") - )); - check!(std::os::windows::fs::symlink_dir( - "hidden/", - tmpdir.path().join("sandbox/indirect") - )); - check!(std::os::windows::fs::symlink_dir( - "/.", - tmpdir.path().join("sandbox/root_link") - )); - } - #[cfg(not(any(unix, windows)))] - { - compile_error!("not implemented yet"); - } - - let tmpdir = check!(Dir::open_ambient_dir(tmpdir.path(), ambient_authority())); - - let sandbox = check!(tmpdir.open_dir("sandbox")); - - for path in [ - "hidden", - "hidden/", - "indirect", - "indirect/", - "root_link", - "root_link/", - ] { - error!( - sandbox.open_dir(path), - "a path led outside of the filesystem" - ); - error!( - sandbox.read_dir(path), - "a path led outside of the filesystem" - ); - error!( - sandbox.canonicalize(path), - "a path led outside of the filesystem" - ); - } -} From d8ea2f568ea38f61131d76b1ce5645d0d6b6809e Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 15 Oct 2026 16:44:10 -0700 Subject: [PATCH 2/9] Fix an unused import warning. --- cap-primitives/src/fs/manually/open.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/cap-primitives/src/fs/manually/open.rs b/cap-primitives/src/fs/manually/open.rs index 20a4b546..83129071 100644 --- a/cap-primitives/src/fs/manually/open.rs +++ b/cap-primitives/src/fs/manually/open.rs @@ -8,7 +8,6 @@ use crate::fs::{ }; #[cfg(any(target_os = "android", target_os = "linux", target_os = "freebsd"))] use rustix::fs::OFlags; -use std::borrow::Cow; use std::ffi::OsStr; use std::path::{Component, Path, PathBuf}; use std::{fs, io, mem}; From aede683a522a3965f6d5587766a19a5c654b5b63 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 15 Oct 2026 17:53:57 -0700 Subject: [PATCH 3/9] Fix test compilation on Windows. --- tests/fs_additional.rs | 54 ++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/tests/fs_additional.rs b/tests/fs_additional.rs index 967a3cab..2c0c26d7 100644 --- a/tests/fs_additional.rs +++ b/tests/fs_additional.rs @@ -1426,17 +1426,26 @@ fn trailing_slash_symlink() { let sandbox = check!(tmpdir.open_dir("sandbox")); for path in ["hidden", "hidden/", "indirect", "indirect/"] { - error!( - sandbox.open_dir(path), - "a path led outside of the filesystem" + let err = sandbox.open_dir(path).unwrap_err(); + assert!( + err.to_string() + .contains("a path led outside of the filesystem"), + "{:?}", + err ); - error!( - sandbox.read_dir(path), - "a path led outside of the filesystem" + let err = sandbox.read_dir(path).unwrap_err(); + assert!( + err.to_string() + .contains("a path led outside of the filesystem"), + "{:?}", + err ); - error!( - sandbox.canonicalize(path), - "a path led outside of the filesystem" + let err = sandbox.canonicalize(path).unwrap_err(); + assert!( + err.to_string() + .contains("a path led outside of the filesystem"), + "{:?}", + err ); } } @@ -1495,17 +1504,26 @@ fn trailing_slash_symlink_more() { "root_link", "root_link/", ] { - error!( - sandbox.open_dir(path), - "a path led outside of the filesystem" + let err = sandbox.open_dir(path).unwrap_err(); + assert!( + err.to_string() + .contains("a path led outside of the filesystem"), + "{:?}", + err ); - error!( - sandbox.read_dir(path), - "a path led outside of the filesystem" + let err = sandbox.read_dir(path).unwrap_err(); + assert!( + err.to_string() + .contains("a path led outside of the filesystem"), + "{:?}", + err ); - error!( - sandbox.canonicalize(path), - "a path led outside of the filesystem" + let err = sandbox.canonicalize(path).unwrap_err(); + assert!( + err.to_string() + .contains("a path led outside of the filesystem"), + "{:?}", + err ); } } From 720d36e944970b4a5c3ca939d1141d63eb3f14a9 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 15 Oct 2026 17:58:25 -0700 Subject: [PATCH 4/9] Pin the js-sys version for the MSRV build. --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index df0038f9..5d433fdd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -403,6 +403,7 @@ jobs: - name: Use specific dependency versions for Rust 1.70 compatibility. run: | cargo update --package=once_cell --precise=1.20.3 + cargo update --package=js-sys --precise=0.3.85 cargo update --package=uuid --precise=1.20.0 # Don't use --all-features because some of the features have dependencies From 8e2bc4e3d4faa009b3a1824d325c4362f93b3b82 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 15 Oct 2026 18:04:50 -0700 Subject: [PATCH 5/9] Pin tempfile for the MSRV build. --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d433fdd..d3c372b5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -405,6 +405,7 @@ jobs: cargo update --package=once_cell --precise=1.20.3 cargo update --package=js-sys --precise=0.3.85 cargo update --package=uuid --precise=1.20.0 + cargo update --package=tempfile --precise=3.25.0 # Don't use --all-features because some of the features have dependencies # that don't work on newer Rust versions. From 2b2eca21599bcaeeadafe819351d5327f6b4f6ef Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 15 Oct 2026 18:05:00 -0700 Subject: [PATCH 6/9] Update cargo-fuzz to a non-ancient version. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d3c372b5..a5261562 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -423,7 +423,7 @@ jobs: - uses: ./.github/actions/install-rust with: toolchain: nightly - - run: cargo install cargo-fuzz --vers "^0.11" + - run: cargo install cargo-fuzz --vers "^0.13" - run: cargo fetch working-directory: ./fuzz - run: cargo fuzz build --dev From ed31648f88e807fa3170b5e2d75b187842df7e7d Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 15 Oct 2026 18:06:36 -0700 Subject: [PATCH 7/9] Fix expected error messages on Windows. --- tests/fs_additional.rs | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/tests/fs_additional.rs b/tests/fs_additional.rs index 2c0c26d7..033b7393 100644 --- a/tests/fs_additional.rs +++ b/tests/fs_additional.rs @@ -1427,26 +1427,11 @@ fn trailing_slash_symlink() { for path in ["hidden", "hidden/", "indirect", "indirect/"] { let err = sandbox.open_dir(path).unwrap_err(); - assert!( - err.to_string() - .contains("a path led outside of the filesystem"), - "{:?}", - err - ); + assert_eq!(err.kind(), io::ErrorKind::InvalidFilename, "{:?}", err); let err = sandbox.read_dir(path).unwrap_err(); - assert!( - err.to_string() - .contains("a path led outside of the filesystem"), - "{:?}", - err - ); + assert_eq!(err.kind(), io::ErrorKind::InvalidFilename, "{:?}", err); let err = sandbox.canonicalize(path).unwrap_err(); - assert!( - err.to_string() - .contains("a path led outside of the filesystem"), - "{:?}", - err - ); + assert_eq!(err.kind(), io::ErrorKind::InvalidFilename, "{:?}", err); } } From 80179c3d3d01e3163f476879922f3893daa6aab5 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 15 Oct 2026 18:51:56 -0700 Subject: [PATCH 8/9] Relax error expectations further. --- tests/fs_additional.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/fs_additional.rs b/tests/fs_additional.rs index 033b7393..891ec1ba 100644 --- a/tests/fs_additional.rs +++ b/tests/fs_additional.rs @@ -1426,12 +1426,9 @@ fn trailing_slash_symlink() { let sandbox = check!(tmpdir.open_dir("sandbox")); for path in ["hidden", "hidden/", "indirect", "indirect/"] { - let err = sandbox.open_dir(path).unwrap_err(); - assert_eq!(err.kind(), io::ErrorKind::InvalidFilename, "{:?}", err); - let err = sandbox.read_dir(path).unwrap_err(); - assert_eq!(err.kind(), io::ErrorKind::InvalidFilename, "{:?}", err); - let err = sandbox.canonicalize(path).unwrap_err(); - assert_eq!(err.kind(), io::ErrorKind::InvalidFilename, "{:?}", err); + let _err = sandbox.open_dir(path).unwrap_err(); + let _err = sandbox.read_dir(path).unwrap_err(); + let _err = sandbox.canonicalize(path).unwrap_err(); } } From ee87f6d7e28358c930c51fa8700bfe1e28563160 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 15 Oct 2026 19:21:11 -0700 Subject: [PATCH 9/9] Relax error expectations further on another test. --- tests/fs_additional.rs | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/tests/fs_additional.rs b/tests/fs_additional.rs index 891ec1ba..1d408853 100644 --- a/tests/fs_additional.rs +++ b/tests/fs_additional.rs @@ -1486,26 +1486,8 @@ fn trailing_slash_symlink_more() { "root_link", "root_link/", ] { - let err = sandbox.open_dir(path).unwrap_err(); - assert!( - err.to_string() - .contains("a path led outside of the filesystem"), - "{:?}", - err - ); - let err = sandbox.read_dir(path).unwrap_err(); - assert!( - err.to_string() - .contains("a path led outside of the filesystem"), - "{:?}", - err - ); - let err = sandbox.canonicalize(path).unwrap_err(); - assert!( - err.to_string() - .contains("a path led outside of the filesystem"), - "{:?}", - err - ); + let _err = sandbox.open_dir(path).unwrap_err(); + let _err = sandbox.read_dir(path).unwrap_err(); + let _err = sandbox.canonicalize(path).unwrap_err(); } }