From c84f1f41fbdd1360495d7a8c316e0e69cac12a73 Mon Sep 17 00:00:00 2001 From: auronandace Date: Thu, 18 Jun 2026 12:06:56 +0100 Subject: [PATCH 1/3] use SYMLOOP_MAX in resolve_sym_links in redox path --- src/header/limits/mod.rs | 3 +++ src/platform/redox/path.rs | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/header/limits/mod.rs b/src/header/limits/mod.rs index c7de1bb3e5..462a76f5cb 100644 --- a/src/header/limits/mod.rs +++ b/src/header/limits/mod.rs @@ -101,6 +101,7 @@ pub const _POSIX_SIGQUEUE_MAX: c_long = 32; pub const _POSIX_SSIZE_MAX: c_long = 32767; pub const _POSIX_STREAM_MAX: c_long = 8; pub const _POSIX_SYMLINK_MAX: c_long = 255; +/// Minimum required value for `SYMLOOP_MAX`. pub const _POSIX_SYMLOOP_MAX: c_long = 8; pub const _POSIX_THREAD_DESTRUCTOR_ITERATIONS: c_long = 4; pub const _POSIX_THREAD_KEYS_MAX: c_long = 128; @@ -145,5 +146,7 @@ pub const PTHREAD_DESTRUCTOR_ITERATIONS: c_long = _POSIX_THREAD_DESTRUCTOR_ITERA // TODO: What should this limit be? Both glibc and musl have it as 1024 pub const PTHREAD_KEYS_MAX: c_long = 4096 * 32; pub const PTHREAD_STACK_MIN: c_long = 65536; +/// Maximum number of symbolic links that can be reliably traversed in the +/// resolution of a pathname in the absence of a loop. pub const SYMLOOP_MAX: c_long = 64; pub const TTY_NAME_MAX: c_long = 32; // "/scheme/pty/".len() + size of usize::MAX as string + 1 diff --git a/src/platform/redox/path.rs b/src/platform/redox/path.rs index 32b35ff618..ac2cb01067 100644 --- a/src/platform/redox/path.rs +++ b/src/platform/redox/path.rs @@ -272,10 +272,8 @@ fn calc_next_abs_path(current_abs: &str, link_target: &str) -> Result { } fn resolve_sym_links(mut current_path_string: String, flags: usize) -> Result { - // TODO: SYMLOOP_MAX - const MAX_LEVEL: usize = 64; // Sym reolve loop - for _ in 0..(MAX_LEVEL - 1) { + for _ in 0..=limits::SYMLOOP_MAX { match open_absolute(¤t_path_string, flags) { Ok(fd) => return Ok(fd), Err(e) if e == Error::new(EXDEV) => { From d0760c2b9055ec0920506cef9730a0e6d34c5824 Mon Sep 17 00:00:00 2001 From: auronandace Date: Thu, 18 Jun 2026 12:25:40 +0100 Subject: [PATCH 2/3] fix amount --- src/platform/redox/path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/redox/path.rs b/src/platform/redox/path.rs index ac2cb01067..a25073e64b 100644 --- a/src/platform/redox/path.rs +++ b/src/platform/redox/path.rs @@ -273,7 +273,7 @@ fn calc_next_abs_path(current_abs: &str, link_target: &str) -> Result { fn resolve_sym_links(mut current_path_string: String, flags: usize) -> Result { // Sym reolve loop - for _ in 0..=limits::SYMLOOP_MAX { + for _ in 0..(limits::SYMLOOP_MAX - 1) { match open_absolute(¤t_path_string, flags) { Ok(fd) => return Ok(fd), Err(e) if e == Error::new(EXDEV) => { From 09ae60562327e69f38db9bd90d44fa038271e35d Mon Sep 17 00:00:00 2001 From: Mathew John Roberts Date: Thu, 18 Jun 2026 13:02:25 +0100 Subject: [PATCH 3/3] Apply 1 suggestion(s) to 1 file(s) Co-authored-by: Wildan Mubarok --- src/platform/redox/path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/redox/path.rs b/src/platform/redox/path.rs index a25073e64b..4151016eb0 100644 --- a/src/platform/redox/path.rs +++ b/src/platform/redox/path.rs @@ -273,7 +273,7 @@ fn calc_next_abs_path(current_abs: &str, link_target: &str) -> Result { fn resolve_sym_links(mut current_path_string: String, flags: usize) -> Result { // Sym reolve loop - for _ in 0..(limits::SYMLOOP_MAX - 1) { + for _ in 0..limits::SYMLOOP_MAX { match open_absolute(¤t_path_string, flags) { Ok(fd) => return Ok(fd), Err(e) if e == Error::new(EXDEV) => {