From 8c9944c50d9e5bce19e1a787b035356461935c4d Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Wed, 26 Jan 2022 22:32:21 +0000 Subject: [PATCH] Fix remove_dir_all on Fuchsia after CVE fix. With the previous `is_dir` impl, we would attempt to unlink a directory in the None branch, but Fuchsia supports returning ENOTEMPTY from unlinkat() without the AT_REMOVEDIR flag because we don't currently differentiate unlinking files and directories by default. On the Fuchsia side I've opened https://fxbug.dev/92273 to discuss whether this is the correct behavior, but it doesn't seem like addressing the error code is necessary to make our tests happy. Updates std's libc crate to include DT_UNKNOWN for Fuchsia. --- Cargo.lock | 4 ++-- library/std/Cargo.toml | 2 +- library/std/src/sys/unix/fs.rs | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa9420658450f..d37ddcb63b38d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1986,9 +1986,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.108" +version = "0.2.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" +checksum = "565dbd88872dbe4cc8a46e527f26483c1d1f7afa6b884a3bd6cd893d4f98da74" dependencies = [ "rustc-std-workspace-core", ] diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 165169aedb315..3aab5d11422a8 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -15,7 +15,7 @@ cfg-if = { version = "0.1.8", features = ['rustc-dep-of-std'] } panic_unwind = { path = "../panic_unwind", optional = true } panic_abort = { path = "../panic_abort" } core = { path = "../core" } -libc = { version = "0.2.108", default-features = false, features = ['rustc-dep-of-std'] } +libc = { version = "0.2.116", default-features = false, features = ['rustc-dep-of-std'] } compiler_builtins = { version = "0.1.66" } profiler_builtins = { path = "../profiler_builtins", optional = true } unwind = { path = "../unwind" } diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index ad656582a0970..1e567b361459e 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -1631,7 +1631,6 @@ mod remove_dir_impl { target_os = "illumos", target_os = "haiku", target_os = "vxworks", - target_os = "fuchsia" ))] fn is_dir(_ent: &DirEntry) -> Option { None @@ -1642,7 +1641,6 @@ mod remove_dir_impl { target_os = "illumos", target_os = "haiku", target_os = "vxworks", - target_os = "fuchsia" )))] fn is_dir(ent: &DirEntry) -> Option { match ent.entry.d_type {