Skip to content

Commit 144aeed

Browse files
authored
Rollup merge of #93152 - ivmarkov:master, r=m-ou-se
Fix STD compilation for the ESP-IDF target (regression from CVE-2022-21658) Commit 54e22eb broke the compilation of STD for the ESP-IDF embedded "unix-like" Tier 3 target, because the fix for [CVE-2022-21658](https://blog.rust-lang.org/2022/01/20/Rust-1.58.1.html) uses [libc flags](https://github.com/esp-rs/esp-idf-svc/runs/4892221554?check_suite_focus=true) which are not supported on the ESP-IDF platform. This PR simply redirects the ESP-IDF compilation to the "classic" implementation, similar to REDOX. This should be safe because: * Neither of the two filesystems supported by ESP-IDF (spiffs and fatfs) support [symlinks](https://github.com/natevw/fatfs/blob/master/README.md) in the first place * There is no notion of fs permissions at all, as the ESP-IDF is an embedded platform that does not have the notion of users, groups, etc. * Similarly, ESP-IDF has just one "process" - the firmware itself - which contains the user code and the "OS" fused together and running with all permissions
2 parents b92a1e9 + 495c7b3 commit 144aeed

File tree

1 file changed

+7
-3
lines changed
  • library/std/src/sys/unix

1 file changed

+7
-3
lines changed

library/std/src/sys/unix/fs.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,8 @@ pub fn chroot(dir: &Path) -> io::Result<()> {
14481448

14491449
pub use remove_dir_impl::remove_dir_all;
14501450

1451-
// Fallback for REDOX
1452-
#[cfg(target_os = "redox")]
1451+
// Fallback for REDOX and ESP-IDF
1452+
#[cfg(any(target_os = "redox", target_os = "espidf"))]
14531453
mod remove_dir_impl {
14541454
pub use crate::sys_common::fs::remove_dir_all;
14551455
}
@@ -1573,7 +1573,11 @@ mod remove_dir_impl {
15731573
}
15741574

15751575
// Modern implementation using openat(), unlinkat() and fdopendir()
1576-
#[cfg(not(any(all(target_os = "macos", target_arch = "x86_64"), target_os = "redox")))]
1576+
#[cfg(not(any(
1577+
all(target_os = "macos", target_arch = "x86_64"),
1578+
target_os = "redox",
1579+
target_os = "espidf"
1580+
)))]
15771581
mod remove_dir_impl {
15781582
use super::{cstr, lstat, Dir, DirEntry, InnerReadDir, ReadDir};
15791583
use crate::ffi::CStr;

0 commit comments

Comments
 (0)